【发布时间】:2017-04-10 11:41:20
【问题描述】:
我的前端有一个按钮,这个按钮与后端对话。 后端正在启动一个远程脚本:
<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$connection = ssh2_connect('192.168.56.180', 22);
ssh2_auth_password($connection, 'root', 'password');
$stream = ssh2_exec($connection, 'python /WATSON/APP/test/testlistrbk.py');
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
echo $stream_out_contente;
fwrite($myfile, $stream_out);
fclose($myfile);
?>
我有 2 个问题,第一个,php 应该等待 python 脚本完成,因为它说 here 但它没有。
第二个,它给了我以下内容:
PHP 警告:fwrite() 期望参数 2 是字符串,资源在 /var/www/html/WEBAPP/wa_start.php 第 41 行给出
【问题讨论】:
-
把
var_dump($stream_out);的输出放在fwrite之前