PHP popen function : How to wait for process completions?

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
pratikpotnis
Forum Newbie
Posts: 4
Joined: Mon Nov 23, 2009 5:50 am

PHP popen function : How to wait for process completions?

Post 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
pratikpotnis
Forum Newbie
Posts: 4
Joined: Mon Nov 23, 2009 5:50 am

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

Post by pratikpotnis »

I am eagerly waiting for the reply.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post 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.
Post Reply