Page 1 of 1

PHP popen function : How to wait for process completions?

Posted: Mon Nov 23, 2009 6:00 am
by pratikpotnis
Hi

I am on windows machine. I am calling two python scripts from PHP code using POPEN function.

$p1 = popen($Python_script1, 'r');
$p2 = popen($Python_script2, 'r');

Python_script1 creates new text file and writes some data into it. this text file is later accessed by Python_script2.

Python_script1 runs fine. But Python_script2 does not run at all.

Is there any way in PHP by which I can wait for 1st process to complete and file is created successfully and then run 2nd process?
SLEEP function is of no use as time taken to finish 1st process is unknown.

Regards,
Pratik

Re: PHP popen function : How to wait for process completions?

Posted: Wed Nov 25, 2009 11:33 pm
by pratikpotnis
I am eagerly waiting for the reply.

Re: PHP popen function : How to wait for process completions?

Posted: Thu Nov 26, 2009 3:35 am
by jackpf
I'm not sure of a way to do this.

Can you not combine the two python scripts into one? Or maybe call the second script from the first. That way it wouldn't matter. You only need to call one script.