Method: Net::SSH::Connection::Session#open_channel
- Defined in:
- lib/net/ssh/connection/session.rb
#open_channel(type = "session", *extra, &on_confirm) ⇒ Object
Requests that a new channel be opened. By default, the channel will be of type “session”, but if you know what you’re doing you can select any of the channel types supported by the SSH protocol. The extra parameters must be even in number and conform to the same format as described for Net::SSH::Buffer.from. If a callback is given, it will be invoked when the server confirms that the channel opened successfully. The sole parameter for the callback is the channel object itself.
In general, you’ll use #open_channel without any arguments; the only time you’d want to set the channel type or pass additional initialization data is if you were implementing an SSH extension.
channel = ssh.open_channel do |ch|
ch.exec "grep something /some/files" do |ch, success|
...
end
end
channel.wait
338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/net/ssh/connection/session.rb', line 338 def open_channel(type = "session", *extra, &on_confirm) local_id = get_next_channel_id channel = Channel.new(self, type, local_id, @max_pkt_size, @max_win_size, &on_confirm) msg = Buffer.from(:byte, CHANNEL_OPEN, :string, type, :long, local_id, :long, channel.local_maximum_window_size, :long, channel.local_maximum_packet_size, *extra) (msg) channels[local_id] = channel end |