2009-05-19 7 views
0

かなりの時間実行されるかもしれないシェルコマンドのフィードバックを提供するにはどうすればよいですか?php long running script

例えば、私はHGクローンを行うスクリプトを必要とする...その後、私のPHPで私は、コール

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

を作るが、私は、コマンドが実際に終了する前に出力を取得することができません。

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. 

それは私が

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

に似たものに私のコマンドを変更する必要がありますを意味しますが、私が作るために、コマンドの後ろにアンパサンド記号が必要なのかという文書(http://www.php.net/manual/en/function.exec.php)に記載されていますそれはバックグラウンドで動作しますか? $ some_fileという情報を使用してユーザーにフィードバックを与えることはできますか?

+0

ている[私は同様の質問に与えた別の答え](見http://stackoverflow.com/questions/ AJAXで正常に動作するpopen

http://php.net/popen

PS 838870/invoke-external-shell-script-from-php-and-send-some-input-to/it/838915#838915) – soulmerge

答えて

1

のpopen: