Using Net::SSH to login to shell and get stateful output

246 views Asked by At

I was reading the documentation (which is pretty outdated). Net-ssh does not have .shell method anymore? how can i achieve signing into the shell, run command and get stdout until its done?

Can anyone point me to a good documentation or advice on how i can do it?

Thank you

1

There are 1 answers

0
Eric Duminil On BEST ANSWER

Net::SSH has been updated a few days ago, and using the first example of the README on the first page of the project did exactly what you wanted to do :

require 'net/ssh'

Net::SSH.start('my_server', 'my_user') do |ssh|
  output = ssh.exec!("ls")
  puts output
end

#=>
# 20130402_083136_DSCF0923.jpg
# 20160715_113357_DSC_6050.jpg
# 20160715_121646_DSC_2.jpg
...
...