ssh2_exec:WAITING进程的下一个运行 - php

我正在使用ssh2_exec运行命令,但看起来它在$ stream1进程结束之前运行$ stream2。如何仅在$ stream1结束后运行$ stream2?

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream1= ssh2_exec($connection, 'command to run');

$stream2 = ssh2_exec($connection, 'command to run 2');

?>

参考方案

问题解决了:

@Barmar建议我看看php.net/manual/en/function.ssh2-exec.php#59324

我通过以下方法解决了问题:

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream1= ssh2_exec($connection, 'command to run');

stream_set_blocking($stream1, true);

// The command may not finish properly if the stream is not read to end
$output = stream_get_contents($stream1);

$stream2 = ssh2_exec($connection, 'command to run 2');

?>

PHP strtotime困境 - php

有人可以解释为什么这在我的服务器上输出为true吗?date_default_timezone_set('Europe/Bucharest'); var_dump( strtotime('29.03.2015 03:00', time()) === strtotime('29.03.2015 04:00�…

PHP-全局变量的性能和内存问题 - php

假设情况:我在php中运行一个复杂的站点,并且我使用了很多全局变量。我可以将变量存储在现有的全局范围内,例如$_REQUEST['userInfo'],$_REQUEST['foo']和$_REQUEST['bar']等,然后将许多不同的内容放入请求范围内(这将是适当的用法,因为这些数据指的是要求自…

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

PHP-从最后一个循环中删除逗号 - php

我在循环时有一个PHP,如果是最后一个循环,我想从,中删除​​最后一个逗号echo '],'; while($ltr = mysql_fetch_array($lt)){ echo '['; echo $ltr['days']. ' ,'. $ltr['name…

PHP Exec SCP不会将文件复制到远程服务器 - php

我需要使用PHP从一个服务器到另一个服务器(我都拥有)的文件。我有以下脚本:<?php exec('scp /home/pat/file1.tst [email protected]:/home/pat/file1.txt'); 我收到此错误:Disallowed system call: SYS_pipe 那是什么错误?以及我该如何…