From: Brian Candler Date: 2009-06-01T21:59:34+09:00 Subject: Re: How can I get command's result code, which executing via ssh A quick check of the SSH protocol spec in RFC 4254 says, in section 6.10: When the command running at the other end terminates, the following message can be sent to return the exit status of the command. Returning the status is RECOMMENDED. No acknowledgement is sent for this message. The channel needs to be closed with SSH_MSG_CHANNEL_CLOSE after this message. The client MAY ignore these messages. byte SSH_MSG_CHANNEL_REQUEST uint32 recipient channel string "exit-status" boolean FALSE uint32 exit_status (and it then goes on to describe the "exit-signal" message as well) Grepping for exit-status in the net-ssh source turns up an example of how to get it: # * "exit-status" : the exit status of the remote process will be reported # as a long integer in the data buffer, which you can grab via # data.read_long. # * "exit-signal" : if the remote process died as a result of a signal # being sent to it, the signal will be reported as a string in the # data, via data.read_string. (Not all SSH servers support this channel # request type.) # # channel.on_request "exit-status" do |ch, data| # puts "process terminated with exit status: #{data.read_long}" # end -- Posted via http://www.ruby-forum.com/.