Reputation: 1618
I'm using phpseclib to ssh into a remote device and download files. This works and when it completes it shows a list of files it has downloaded.
However I'd like it to show each filename as it's downloaded.
The code I'm using is:
$ssh = new Net_SSH2('192.168.0.1');
if (!$ssh->login('user', 'password')) {
exit('Login Failed');
}
function output($str) {
echo "$str";
}
$cmd = "getfiles";
$res = $ssh->exec($cmd, "output");
If I use putty and SSH into the remote device and then run getfiles
it will show each filename on a new line as it is handled.
phpseclib seems to just show the final result, not the live progress.
Is there anyway to make it show the live progress ?
Thanks
Upvotes: 1
Views: 526
Reputation: 1618
I've got this working by updating the output function as follows.
function output($str) {
flush(); ob_flush();
echo "$str<br>";
}
Now the output is shown on a new line.
Upvotes: 1