Reputation: 690
I am trying to run a perl script where I call a 3rd party script. I want to pause execution until the 3rd party script completes and then continue execution.
I have been using the system command with a sleep right after it but its clunky and the duration of the script execution can change.
Any ideas?
Upvotes: 0
Views: 333
Reputation: 56
The system() call does a fork and exec, which means it creates a new child process, runs your command in that child process, and waits for that child process to finish. So, in the typical case system() should be waiting for whatever was executed by system() to finish.
The problem could be that the third party script also does this, in which case you might see the behavior you are describing.
Without more details, it's hard to say. Does your 3rd party script "complete" by handing you a shell prompt back after you execute it manually, or is it still running?
Upvotes: 2
Reputation: 37146
Open a two-way pipe with the external process that allows it to tell the Perl script when it's done.
This is covered in great depth in perldoc perlipc
.
Upvotes: 1