From: Randy Coulman Date: 2012-02-23T01:01:38+09:00 Subject: Detecting an error in Net::SSH#exec! --20cf3010e2c7664d7f04b98fa44e Content-Type: text/plain; charset=ISO-8859-1 When I execute a remote command with Net::SSH#exec!, how do I tell whether 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 else # do something with data end end This only works if the command I'm running writes to stderr if and only if it encounters an error, which seems flaky. How do others deal with this? Thanks, Randy -- Randy Coulman rcoulman@gmail.com Twitter: @randycoulman --20cf3010e2c7664d7f04b98fa44e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable When I execute a remote command with Net::SSH#exec!, how do I tell whether = or not the command succeeded?

So far, this is the way I&= #39;ve found to do it:

Net::SSH.start("host&q= uot;, "username") do | ssh |
=A0 ssh.exec!("some_command") do | channel, stream, data |
=A0 =A0 if stream =3D=3D :stderr
=A0 =A0 =A0 =A0# a= n error occurred
=A0 =A0 else
=A0 =A0 =A0 =A0# do somet= hing with data
=A0 =A0 end
end

This only works if the command I'm ru= nning writes to stderr if and only if it encounters an error, which seems f= laky.

How do others deal with this?

Thanks,
Randy
--
Randy Coulman
rcoulman@gmail.comTwitter: @randycoulman

--20cf3010e2c7664d7f04b98fa44e--