Jump to content

Execute multiple external processes and redirect their output to a file


mercie_s

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.