mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-28 17:48:35 +00:00
Merge pull request #59 from tamagokun/set_exit_status
Get the exit status in ssh
This commit is contained in:
commit
882e019062
@ -709,6 +709,14 @@ class Net_SSH2 {
|
||||
*/
|
||||
var $last_packet;
|
||||
|
||||
/**
|
||||
* Exit status returned from ssh if any
|
||||
*
|
||||
* @var Integer
|
||||
* @access private
|
||||
*/
|
||||
var $exit_status;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
@ -2330,6 +2338,8 @@ class Net_SSH2 {
|
||||
$this->errors[count($this->errors)].= "\r\n" . $this->_string_shift($response, $length);
|
||||
}
|
||||
case 'exit-status':
|
||||
extract(unpack('Cfalse/Nexit_status', $this->_string_shift($response, 5)));
|
||||
$this->exit_status = $exit_status;
|
||||
// "The channel needs to be closed with SSH_MSG_CHANNEL_CLOSE after this message."
|
||||
// -- http://tools.ietf.org/html/rfc4254#section-6.10
|
||||
$this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel]));
|
||||
@ -2973,4 +2983,18 @@ class Net_SSH2 {
|
||||
|
||||
return $this->signature_format . ' ' . base64_encode($this->server_public_host_key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exit status of an SSH command or false.
|
||||
*
|
||||
* @return Integer or false
|
||||
* @access public
|
||||
*/
|
||||
function getExitStatus()
|
||||
{
|
||||
if (is_null($this->exit_status)) {
|
||||
return false;
|
||||
}
|
||||
return $this->exit_status;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user