首页 > 编程知识 正文

php和python对接,phpstudy启动后就停止

时间:2023-05-05 20:10:43 阅读:50383 作者:1141

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

$connection=ssh2_connect (外壳. example.com),22 );

sh2_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

我用以下方法解决了这个问题:

$connection=ssh2_connect (外壳. example.com),22 );

sh2_auth_password($connection,' username ',' password ' );

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

stream_set_blocking($stream1,true );

//thecommandmaynotfinishproperlyifthestreamisnotreadtoend

$ output=stream _ get _ contents ($ stream1);

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

标签: php,ssh

资料来源: https://codeday.me/bug/2019 10 11/1892960.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。