Submit a qsub script SGE

Hello,
I'm working on a SGE cluster and trying to echo the variables passed to the qsub command.

My script is as follows

#!/bin/bash
#$ -V
#$ -cwd
#$ -pe make 10

if [ ! StatedUserName == "$StatedUserName" ] ; then
     echo "Variable is not set"
else
     echo "Variable says: $StatedUserName"
fi

and I run the following command

qsub -v StatedUserName="NB"  hello.sh

and the log output is

Variable says: NB

The above is all fine. But When I run the command without the variable

qsub hello.sh

The log is

Variable says:

Why doesn't it throw an error or state

Variable is not set

Thank you

Never used qsub but I'd be tempted to use:

if [ -z "$StatedUserName" ] ; then

to test for a blank/missing StatedUserName variable

1 Like