ssh-exec
ssh-exec
is a wrapper around Net::SSH based on a
StackOverflow answer,
allowing to easily capture standard output, standard error, and the exit code
of a command executed over Net::SSH.
This gem is hosted at http://rubygems.org/gems/ssh-exec.
Examples
require 'net/ssh'
require 'ssh-exec'
Net::SSH.start('somehost', 'someuser') do |ssh|
result = SshExec.ssh_exec!(ssh, 'echo I am remote host')
puts result.stdout # "I am remote host"
puts result.stderr # ""
puts result.exit_status # 0
result = SshExec.ssh_exec!(ssh, 'false')
puts result.exit_status # 1
end