我有我的前端有一个按钮,这个按钮说话后端。 后端开始远程脚本:PHP:SSH连接和python脚本执行
<?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为字符串,资源上线41 /var/www/html/WEBAPP/wa_start.php给出
放输出;'FWRITE这里 –