I have my front end with a button, this button talks to backend. The backend is starting a remote script :
<?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);
?>
I have 2 issues , First one, php should wait the python script to finish as it said here but it does not.
Second one, It gives me the following :
PHP Warning: fwrite() expects parameter 2 to be string, resource given in /var/www/html/WEBAPP/wa_start.php on line 41