From: Matthew Mucklo Date: 2009-01-23T05:30:47+09:00 Subject: [ruby-core:21529] [Bug #1041] Net:SSH problem with open_channel Bug #1041: Net:SSH problem with open_channel http://redmine.ruby-lang.org/issues/show/1041 Author: Matthew Mucklo Status: Open, Priority: Normal It appears that the open_channel method does not always work when used without passing it a block. Steps to reproduce: require 'net/ssh' ssh = Net::SSH.start('system', 'user', :password => 'password') ch = ssh.open_channel ch.exec 'ls' do |ch, success| end Resultant error: TypeError: can't convert nil into Integer from /usr/lib/ruby/site_ruby/1.8/net/ssh/buffer.rb:294:in `pack' from /usr/lib/ruby/site_ruby/1.8/net/ssh/buffer.rb:294:in `write_long' from /usr/lib/ruby/site_ruby/1.8/net/ssh/buffer.rb:55:in `send' from /usr/lib/ruby/site_ruby/1.8/net/ssh/buffer.rb:55:in `from' from /usr/lib/ruby/site_ruby/1.8/net/ssh/buffer.rb:47:in `step' from /usr/lib/ruby/site_ruby/1.8/net/ssh/buffer.rb:47:in `from' from /usr/lib/ruby/site_ruby/1.8/net/ssh/connection/channel.rb:465:in `send_channel_request' from /usr/lib/ruby/site_ruby/1.8/net/ssh/connection/channel.rb:159:in `exec' from (irb):9 The same does work if open_channel is passed a block, however, like such: require 'net/ssh' ssh = Net::SSH.start('system', 'user', :password => 'password') channel = ssh.open_channel do |ch| ch.exec 'ls' do |ch, success| end end Also it will work if you run ssh.exec! before running ch.exec: require 'net/ssh' ssh = Net::SSH.start('system', 'user', :password => 'password') ch = ssh.open_channel ssh.exec! 'ls' ch.exec 'ls' do |ch, success| end ---------------- $ ruby -v ruby 1.8.7 (2008-06-20 patchlevel 22) [ia64-hpux11.23] $ uname -a HP-UX srvr B.11.23 U ia64 4026996514 unlimited-user license # srvr is the name of the server ---------------- ---------------------------------------- http://redmine.ruby-lang.org