Method: Net::SSH::Connection::Channel#send_channel_request
- Defined in:
- lib/net/ssh/connection/channel.rb
#send_channel_request(request_name, *data, &callback) ⇒ Object
Sends a new channel request with the given name. The extra data
parameter must either be empty, or consist of an even number of arguments. See Net::SSH::Buffer.from for a description of their format. If a block is given, it is registered as a callback for a pending request, and the packet will be flagged so that the server knows a reply is required. If no block is given, the server will send no response to this request. Responses, where required, will cause the callback to be invoked with the channel as the first argument, and either true or false as the second, depending on whether the request succeeded or not. The meaning of “success” and “failure” in this context is dependent on the specific request that was sent.
channel.send_channel_request "shell" do |ch, success|
if success
puts "user shell started successfully"
else
puts "could not start user shell"
end
end
Most channel requests you’ll want to send are already wrapped in more convenient helper methods (see #exec and #subsystem).
468 469 470 471 472 473 474 475 |
# File 'lib/net/ssh/connection/channel.rb', line 468 def send_channel_request(request_name, *data, &callback) info { "sending channel request #{request_name.inspect}" } msg = Buffer.from(:byte, CHANNEL_REQUEST, :long, remote_id, :string, request_name, :bool, !callback.nil?, *data) connection.(msg) pending_requests << callback if callback end |