multiple exec statements - run each prog in bg - no waiting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

multiple exec statements - run each prog in bg - no waiting

Post by dickey »

I have a script the likes of

Code: Select all

 
// launcher.php
exec("externalprog1.bat",$output);// externalprog1.bat contains a single line like-->@C:\php\php.exe -q process1.php
exec("externalprog2.bat",$output);// externalprog2.bat contains a single line like-->@C:\php\php.exe -q process2.php
exec("externalprog3.bat",$output);// externalprog3.bat contains a single line like-->@C:\php\php.exe -q process3.php
exec("externalprog4.bat",$output);// externalprog4.bat contains a single line like-->@C:\php\php.exe -q process4.php
 
Currently, when launcher.php is run, only the first external program is executed (although I have run each batch file from the cmd line successfully).

What I would like to happen is to have each external program run immediately as a background process, and not wait until externalprog1 is finished before executing externalprog2 etc.

I simply want to execute them all no waiting.

PHP5.2.0/Apache2.2/WinXPPro SP2 (by way of background).

Thanks and kind regards, Andrew
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: multiple exec statements - run each prog in bg - no waiting

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

Re: multiple exec statements - run each prog in bg - no waiting

Post by dickey »

Thanks Vladsun, your recommended view topic was most helpful. I can now exec multiple programs as background processes quickly and return control to the main script.

Kind regards,

Andrew
Post Reply