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.
#$ -N $2
. If your script is a bourne shell script then this is a comment (it begins with#
) but you seem to mean it as something else. – Limewater#PBS
directive but it doesn't mention#$
at all, so I still don't know what that means. In any case, it sounds like thoseqsub
directives are interpreted byqsub
itself before the script is run, so it would make sense that arguments which are passed to the script once it gets executed don't enter into the processing of such directives. I think you're supposed to supply a static string for the name of the job. – Limewater-l
in the shebang line of the script is suspicious.-l
forces a login shell, which will normally invoke/etc/profile
functionality designed for interactive shells. No shell script should need that. – Limewater#!/bin/sh
means something different than#!/bin/bash
and also, when you dosh foo.sh
you're bypassing that specification completely. see: https://mcmap.net/q/421695/-what-is-the-use-meaning-of-quot-bin-sh-quot-in-shell-scripting – Impermeableqsub
will answer your question aboutqsub
parameter passing. As for the-l
option, you shouldn't need it. If your script doesn't work without it then something should be corrected. – Limewater