How to properly pass on an environment variable to Sun Grid Engine? How to properly pass on an environment variable to Sun Grid Engine? bash bash

How to properly pass on an environment variable to Sun Grid Engine?


What I've been always doing is the following:

##send.shexport a=10qsub ./run.sh

and the script run.sh:

##run.sh#$ -Vecho $a

when I call send.sh, the .o has an output of 10.


Assuming that your variable is just an incrementing counter: You can use Array Jobs to achieve this. This will set an $SGE_TASK_ID environment variable to the count which you can then copy to $i or use directly.

If the variable is anything else, then I think you'll have to generate multiple job scripts and submit each; that's the "solution" I use when I have loads of jobs with differing parameters.


I'm not certain you can pass variables by their name through qsub. I've had success with passing values (you should probably write a front-end script for this instead of doing it interactively):

$ export ii=19$ qsub -N "test_env" -cwd -v i=$ii run.sh