I have a shell script foo.sh
which is a qsub job with content:
#!/bin/bash -l
#$ -S /bin/bash
#$ -N $2
echo $1
I would like to pass two arguments. If I call qsub foo.sh a b the first argument gets correctly processed and echoed to the command line as 'a'. However, I do not know how to pass an argument in the second case starting with '#$ -N'. In this case $2 does not get evaluated to 'b' but actually '$2' is set. Help would be much appreciated.
No you can't. The # at the beginning of the line makes it so that the $2 won't be replaced by the argument to the script. The way to do what you're trying to do is
qsub foo.sh -N <name>