Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks, novices, postulants, aspirants, benefactors,...
I have a Perl script which submits several jobs to an SGE grid cluster, later jobs being dependent on the output of previous ones (I use -sync yes to make sure they are run in order). Until now, I simply submitted the jobs using system, but I would like to achieve that the main script dies when a job in the sequence fails, instead of pointlessly going on. Since this occurs several times in my code, I used a subroutine to code it:
In the subroutine, I want to capture the exit code and possible message printed by SGE so I can potentially terminate the main script. I looked up the module IO::CaptureOutput and tried the following:&qsub("qsub $qsub_options $subscript $script_args", "Some files are broken");
sub qsub { my ($cmd, $error_message) = @_; my @cmd = @{ $cmd }; my ($stdout,$stderr,$success,$exit_code) = capture_exec(@cmd); if (($exit_code > 0) || ($stderr)) { die "$error_message\n"; } }
This doesn't work, however. I get an error related to strict because of the @cmd array, but I don't understand why it has to be an array. Actually, I tried using a scalar first, but it didn't work either.
For reference, the relevant part of the SGE man page says: "If -sync y is used ... If all the job's tasks complete successfully, qsub's exit code will be ... 0 ... If any of the job's tasks fail ..., qsub will print out an error message ... and will have an exit code of 1".
Can somebody explain what's going on and help me fix it?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capturing SGE exit code in Perl
by Anonymous Monk on May 28, 2012 at 20:46 UTC | |
|
Re: Capturing SGE exit code in Perl
by runrig (Abbot) on May 31, 2012 at 16:43 UTC | |
|
Re: Capturing SGE exit code in Perl
by thargas (Deacon) on May 30, 2012 at 18:39 UTC | |
by Anonymous Monk on May 31, 2012 at 16:21 UTC |