Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes net/ssh/shell work with Ruby 1.9.3?
    text
    copied!<p>I am trying the sample code from: <a href="http://www.ruby-doc.org/gems/docs/n/net-ssh-shell-0.2.0/README_rdoc.html" rel="nofollow">http://www.ruby-doc.org/gems/docs/n/net-ssh-shell-0.2.0/README_rdoc.html</a></p> <pre><code>require 'net/ssh' require 'net/ssh/shell' Net::SSH::start('host', 'user', :password=&gt;'password') do |ssh| puts ssh.exec!("hostname") ssh.shell do |sh| sh.execute "cd /usr/local" sh.execute "pwd" sh.execute "export FOO=bar" sh.execute "echo $FOO" p=sh.execute "grep dont /tmp/notexist" puts "Exit Status:#{p.exit_status}" puts "Command Executed:#{p.command}" end end </code></pre> <p>I do pass in my password, and confirmed that I am logged in by testing with <code>ssh.exec!("hostname")</code>. I am expecting some output from the <code>pwd</code> and <code>echo</code> commands, but I don't see it. In addition, the program/script just hangs at the end. I am using Ruby 1.9.3p429 (2013-05-15) [i386-mingw32] on Windows. I tested against the SSH server on OS X, and Ubuntu.</p> <p>Here my output. The trace is from me doing Ctrl-C:</p> <pre><code>C:\sb&gt;ruby test.sh Exit Status: Command Executed:grep dont /tmp/notexist C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/ruby_compat.rb:22: in `select': Interrupt from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/ruby_compat.rb:22:in `io_select' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:201:in `process' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:161:in `block in loop' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:161:in `loop' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:161:in `loop' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/session.rb:110:in `close' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh.rb:191:in `start' from test.sh:5:in `&lt;main&gt;' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload