|No such thing as a small change|
Calling External Programby Anonymous Monk
|on Jun 03, 2009 at 20:58 UTC||Need Help??|
Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
I apoligize in advance, but company restrictions forbid me from posting any code. Even though I had to teach myself perl, I will try to make my request for wisdom as clear as possible.
I'm trying to write a script that calls 2 other perl scripts, then a MATLAB script followed by a 3rd perl script. I have no problem getting any of the programs to start and run correctly, but I can't seem to figure out how to make the last perl script wait until the MATLAB script is finished before it is called.
For error checking I decided to call MATLAB using system(), because I thought perl waits until the program is finished and assigns a value of 0 upon a succesful exit. What system seems to actually do is return 0 once MATLAB starts.
The goal is to automate these 4 tasks to run every night after my co-workers and I leave for the day. The MATLAB program and last perl script are very resource-intensive processes that take at least 4 hours each to complete. Because the present version of my script calls the last script before MATLAB is finished, both programs run at the same time and crash the system.
My question is, how can I force perl to wait until MATLAB is finished before calling the last program? I currently call MATLAB in background mode (the program does not load as a GUI like normal, and returns all results in a log file upon exit).