for MY_VAR in green yellow blue red; do qsub test.pbs; done
qsub: cannot send environment with the job
qsub: cannot send environment with the job
qsub: cannot send environment with the job
qsub: cannot send environment with the job
It does work with
for MY_VAR in green yellow blue red; do qsub -V test.pbs; done
So long as I comment out # PBS -v MY_VAR
Both the manual and man page suggest that -v in the script should work. What am I doing wrong?
I wont lie, that’s not obvious. And it doesn’t solve the problem of either there is a bug or the documentation is wrong wrt #PBS -v MY_VAR and qsub -V? Unless what I’m missing is that it needs to be #PBS -v var=$MY_VAR ?
To slightly rephrase what @scc said. There are “shell variables” and “environment variables”. shell variabels are only visible to the current bash shelll process… not do it’s child processes (in this instance the qsub command). When you “export” a variable the shell will include the variable (and it’s value) in the environment of any child processes. To show this isn’t just a qsub thing… here’s an example using the “env” command (which print out any environment variables it inherits from the shell:
[arwild1@hplcva01 ~]$ # look ma, no output
[arwild1@hplcva01 ~]$ for MY_VAR in green yellow blue red; do env |egrep MY_VAR; done
[arwild1@hplcva01 ~]$ # now with output
[arwild1@hplcva01 ~]$ export MY_VAR; for MY_VAR in green yellow blue red; do env |egrep MY_VAR; done
MY_VAR=green
MY_VAR=yellow
MY_VAR=blue
MY_VAR=red