I've used libraries like Fabric (Python) to perform various tasks on a remote server. When I run tasks via this library, I get the output from the remote server as the actions are happening. For example, if the task is executing a git pull
on the server, I get the line by line output of that as it happens.
However, when I look at the various PHP SSH libs and the SSH2 extension. It appears there is only a way to get ALL of the output of from the command after it has already happened, in one long string. I would like to be fed output back from the remote server as the task is running. Is this possible? In pseudocode, this is kind of what I'm looking for:
Server::run('git pull origin master', function($output)
{
echo $output.PHP_EOL;
});
Got this working. You can just read the stream returned by ssh2_exec
using fgets
in a loop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With