Collecting job id from qsub command

Hello. Hopefully this is the right forum, did a search and found some similar questions here.

I'm trying to find out if there is a way to get the job id while submitting a job using qsub. I want to monitor the list of active jobs using qstat and when my jobid is no longer on the active list, I want to start post processing.

i.e.

counter = 0
for x in xrange(1,10):
    counter += 1:
    pidList[counter] = qsub script.sh i

You want to run a bunch and then just wait for them to finish? I would just use shell

( job1 & job2 & job3 & wait ; job4 )

These jobs are not running on the local node though. They are running on multiple remote nodes.

If you capture stdout or stderr from ssh to a:

( . . . ) 2>&1 | cat -u >>$LOG

then the cat will run untill all children finish and close stdout, stderr.