mercie_s Posted June 11, 2009 Share Posted June 11, 2009 Hello, I have a python script and I would like to run multiple instances of that same file with different parameters, collect the output from each process and format it, and then throw that formatted output into a file. So far I have: <?php // Process form information to get my parameters .... // Create an array that will hold the outputs of all our processes $processes = array(); // Now loop through our variable arrays and create the processes for($n = 0; $n < count($N); $n++) { for($j = 0; $j < count($J); $j++) { // Create another process and push it onto our array array_push( $processes, exec("python ../../usr/lib/cgi-bin/CFT.py" . " -N " . $N[$n] . " -J " . $J[$j] . " -d " . $dRoot . " -i " . $iDataSet) ); } } ?> My question is, if I now loop through the processes array, will the variables there be filled with the output of my processes, or will they be empty because php doesn't wait for the processes to finish running before it continues with the rest of the program? Is there a better way to do this? Thank you! Mercie Quote Link to comment Share on other sites More sharing options...
J.Daniels Posted June 11, 2009 Share Posted June 11, 2009 The passthru() function will execute a command and return the full output to an array. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.