Hi,
I'm trying to execute some commands via the exec / shell_exec / system / passthru / popen PHP functions.
The commands are getting executed successfully, but they're not returning any output, which they would normally do, if they are executed in a terminal/shell environment:
http://i.minus.com/ipySNqCnFn5iG.png
http://i.minus.com/ibmq8Cer2yOAOR.png
What I expect:
To execute a particular command and to get real-time raw output from the executed commands and display them to the browser/php page SIMULTANEOUSLY while the command is being executed.
So for example, if a file is being transferred via a command, and the program being executed is supposed to return:
3764520 (1%) 1.52M/s eta:2m [Sending data]I need this exact information to be passed on to the browser / PHP script without any intervention. I am aware about the passthru function which should be used for this purpose, but all of the functions I've used return NO output AT ALL, while the commands itself get executed successfully without any problem.
What I get:
The browser window is totally empty and no output is displayed, even though the command itself was successfully executed.
What I have tried:
<?php
$command = "lftp -u username,password ftp.website.com -e 'set ftp:ssl-allow off; put /var/www/folder/file.zip; bye'" . " 2>&1";
$handle = popen ($command, 'r');
while (($buffer = fgets ($handle, 4096)) !== false)
{
echo $buffer . "\n";
ob_flush();
flush();
}
pclose ($handle);
?>
and
<?php
$command = "/usr/bin/lftp -u username,password ftp.website.com -e 'set ftp:ssl-allow off; put /var/www/folder/file.zip; bye'" . " 2>&1";
system ($command);
?>
and
<?php
$command = "/usr/bin/lftp -u username,password ftp.website.com -e 'set ftp:ssl-allow off; put /var/www/folder/file.zip; bye'" . " 2>&1";
exec ($command);
?>
Command(s) I'm trying to execute:
executes properly, but no output displayed:lftp -u username,password ftp.website.com -e 'set ftp:ssl-allow off; put /var/www/folder/file.zip; bye' 2>&1
executes properly, and output is displayed:ls -lsra /home/username/files/