2009-05-19 7 views
0

Comment puis-je fournir des commentaires sur une commande shell qui peut s'exécuter pendant un certain temps?php long running script

par exemple, j'ai besoin d'un script qui ne hg clone ... puis dans mon php je fais un appel

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

mais je ne serais pas en mesure d'obtenir la sortie avant que la commande se termine réellement. Il est indiqué dans la documentation (http://www.php.net/manual/en/function.exec.php) qui

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. 

que cela voudrait dire que je devrais changer ma commande pour quelque chose de similaire à

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

Ai-je besoin esperluette à l'arrière de la commande pour faire ça marche en arrière-plan? puis-je utiliser l'information $ un_fichier pour fournir des commentaires à l'utilisateur?

+0

Jetez un oeil à [une autre réponse que je donnais à une question similaire] (http://stackoverflow.com/questions/ 838870/invoke-shell-script-from-php-et-send-some-input-to/838915 # 838915) – soulmerge

Répondre