What i have
This is working but i want to get result of long running scripts
Start the sh script and then calling an ajax funciton which is checking every 2 sec and show the result. is this possible?
$connection = ssh2_connect('192.168.1.1', 22);
ssh2_auth_password($connection, 'user', 'password');
$stream = ssh2_exec($connection, 'sh /test.sh');
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
echo stream_get_contents($stream_out);
What i will
$connection = ssh2_connect('192.168.1.1', 22);
ssh2_auth_password($connection, 'user', 'password');
$stream = ssh2_exec($connection, 'sh /test.sh');
$session->stream = $stream; <-##### Here i save it in a session ######
########################################################
I want to save the Stream in a session variable
and check the result anytime while the process is still running
Is this possible ?
##########################################################
$stream = $session->stream; <-##### Here i get it from the session ######
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
echo stream_get_contents($stream_out);
When i do this i get the follwing error:
stream_set_blocking() expects parameter 1 to be resource, integer given