When I execute a remote command with Net::SSH#exec!, how do I tell
or not the command succeeded?
So far, this is the way I’ve found to do it:
Net::SSH.start(“host”, “username”) do | ssh |
ssh.exec!(“some_command”) do | channel, stream, data |
if stream == :stderr
# an error occurred
# do something with data
This only works if the command I’m running writes to stderr if and only
it encounters an error, which seems flaky.
How do others deal with this?