qsub
has a very predictable output. Many automated submission systems (such as Grid interfaces) simply parse the output from qsub
, looking for the jobid.
An example of parsing is available from the BLAHP project (European grid middleware).
jobID=`${pbs_binpath}/qsub $bls_tmp_file` # actual submission
...
# The job id is actually the first numbers in the string (slurm support)
jobID=`echo $jobID | awk 'match($0,/[0-9]+/){print substr($0, RSTART, RLENGTH)}'`
(source)
This code has been used in production for many years, and has worked for qsub
in both PBS, PBS Pro, and SLURM.