mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-09-22 04:29:01 +00:00
SSH2: add $callable parameter to exec()
This commit is contained in:
parent
f596c577cf
commit
dc76cf5b8e
@ -2013,7 +2013,7 @@ class Net_SSH2 {
|
|||||||
* @return String
|
* @return String
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function exec($command, $block = true)
|
function exec($command, $callback = NULL)
|
||||||
{
|
{
|
||||||
$this->curTimeout = $this->timeout;
|
$this->curTimeout = $this->timeout;
|
||||||
$this->stdErrorLog = '';
|
$this->stdErrorLog = '';
|
||||||
@ -2097,7 +2097,7 @@ class Net_SSH2 {
|
|||||||
|
|
||||||
$this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_DATA;
|
$this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_DATA;
|
||||||
|
|
||||||
if (!$block || $this->in_request_pty_exec) {
|
if ($callback === false || $this->in_request_pty_exec) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2106,11 +2106,15 @@ class Net_SSH2 {
|
|||||||
$temp = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC);
|
$temp = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC);
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case $temp === true:
|
case $temp === true:
|
||||||
return $output;
|
return is_callable($callback) ? true : $output;
|
||||||
case $temp === false:
|
case $temp === false:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
$output.= $temp;
|
if (is_callable($callback)) {
|
||||||
|
$callback($temp);
|
||||||
|
} else {
|
||||||
|
$output.= $temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user