Php long running script

how can I provide feedback for a shell command that might run for a while?

for example i need a script that does hg clone ... then in my php i make a call

exec('hg clone ...', $output, $return_value);

      

but I would not be able to get the result before the command actually ends. The documentation ( http://www.php.net/manual/en/function.exec.php ) states that

Note: If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

      

this would mean that I have to change my command to something similar to

exec('hg clone 2>&1 $some_file', $output, $return_value);

      

Do I need the ampersand character at the end of the command to keep it running in the background? and can I use the $ some_file information to provide feedback to the user?

0


a source to share


1 answer


POPEN:

http://php.net/popen



PS popen works great with AJAX

+1


a source







All Articles