You can capture the exit code via the on_request callback:
ssh.open_channel do |channel|
channel.on_request("exit-status") do |ch, data|
code = data.read_long
puts "finished with exit code: #{code}"
end
end
The #on_request callback is whenever the server sends a channel-
request packet to the client, with a type equal to the argument. In
this case, you're trapping all "exit-status" channel requests. The
data parameter is a Net::SSH::Buffer object containing the request-
specific data for the request. For exit-status, this will be a single
long integer, representing the exit status.
Hope that helps! - Jamis On Aug 26, 2008, at 4:31 PM, Jeff wrote:
Feel free to flame and redirect me if there's a more appropriate mailing list/group for net-ssh questions.... Starting to learn how to use the net-ssh library (2.0.3). Thanks, Jamis, for all your work on this. Trying to grok the exec method, on either Session or Channel. I've learned how to capture stdout and stderr. Is there a way to also capture the exit code from the remote process? Some tools that I have to call remotely will return non-zero if they fail, in which case I want to abort my script. Thanks! Jeff --~--~---------~--~----~------------~-------~--~----~ To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/capistrano -~----------~----~----~----~------~----~------~--~---
smime.p7s
Description: S/MIME cryptographic signature
