Merge pull request #85 from epoplive/master

added getStdError method to get stdErr, even when quiet mode enabled
This commit is contained in:
terrafrost 2013-03-22 06:25:33 -07:00
commit 9bf633d689

View File

@ -732,6 +732,12 @@ class Net_SSH2 {
*/ */
var $in_request_pty_exec = false; var $in_request_pty_exec = false;
/**
* Contents of stdError
* @access private
*/
var $stdErrorLog;
/** /**
* Default Constructor. * Default Constructor.
* *
@ -1789,6 +1795,13 @@ class Net_SSH2 {
$this->timeout = $this->curTimeout = $timeout; $this->timeout = $this->curTimeout = $timeout;
} }
/**
* Get the output from stdError
*/
function getStdError(){
return $this->stdErrorLog;
}
/** /**
* Execute Command * Execute Command
* *
@ -1803,6 +1816,7 @@ class Net_SSH2 {
function exec($command, $block = true) function exec($command, $block = true)
{ {
$this->curTimeout = $this->timeout; $this->curTimeout = $this->timeout;
$this->stdErrorLog = '';
if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
return false; return false;
@ -2395,9 +2409,6 @@ class Net_SSH2 {
$this->channel_buffers[$client_channel][] = $data; $this->channel_buffers[$client_channel][] = $data;
break; break;
case NET_SSH2_MSG_CHANNEL_EXTENDED_DATA: case NET_SSH2_MSG_CHANNEL_EXTENDED_DATA:
if ($skip_extended || $this->quiet_mode) {
break;
}
/* /*
if ($client_channel == NET_SSH2_CHANNEL_EXEC) { if ($client_channel == NET_SSH2_CHANNEL_EXEC) {
$this->_send_channel_packet($client_channel, chr(0)); $this->_send_channel_packet($client_channel, chr(0));
@ -2406,6 +2417,10 @@ class Net_SSH2 {
// currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR // currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR
extract(unpack('Ndata_type_code/Nlength', $this->_string_shift($response, 8))); extract(unpack('Ndata_type_code/Nlength', $this->_string_shift($response, 8)));
$data = $this->_string_shift($response, $length); $data = $this->_string_shift($response, $length);
$this->stdErrorLog .= $data;
if ($skip_extended || $this->quiet_mode) {
break;
}
if ($client_channel == $channel) { if ($client_channel == $channel) {
return $data; return $data;
} }