I am currently working with the bsub job submission system from Platform LSF. I need to submit job scripts, but I am running into a problem with passing arguments to the job script.
What I need is as follows: the job script is a bash script that takes one command line argument. I need to pass the argument to that script, then redirect the script to be used as input to bsub. The problem is that the argument isn't being applied to the script.
I have tried:
bsub < script.bsub 1
script.bsub is my script and 1 is the numeric argument. This approach doesn't work. The 1 is being treated as an argument to bsub.
bsub < "script.bsub 1"
This approach makes bsub treat the entire double-quoted line as a filename.
Is there a way to apply a command line argument to a script first, then redirect that script with the argument into another program as input? If anyone has experience with bsub that would be even better.
UPDATE AND WORKAROUND:
It seems applying a command line argument to a bsub file is a very complicated process. I tried the HEREDOC method stated below, but bsub acted as if the script filename was a command. So the easiest way to get around this problem is just to not use input redirection at all.
To pass an argument to a script to be run in bsub, first specify all bsub arguments in the command line rather than in the script file. Then to run the script file, use
"sh script.sh [arg]"
after all of the bsub arguments. Thus the entire line will look something like:
bsub -q [queue] -J "[name]" -W 00:10 [other bsub args] "sh script.sh [script args]"
This doesn't answer my original question, but at least with bsub this is the simplest resolution to my problem.