5

I'm trying to submit commands to the LSF scheduler with bsub but this command includes a parameter value that must be quoted and contains a semicolon.

Here is a simple command to illustrate my problem

bsub -o t.o -e t.e echo "foo;bar"

it fails with "line 8: bar: command not found", so I thought I could escape the semicolon but this

bsub -o t.o -e t.e echo "foo\;bar"

causes the same error, so does this

bsub -o t.o -e t.e echo 'foo;bar'

I know I can get around it by writing the command to a script file and executing that as the bsub command but in this case I am going to test a number of parameters and it would be so much handier to just modify the bsub command rather than editing a shell script each time.

Thanks for your help!

tospo
  • 646
  • 9
  • 17

1 Answers1

2

One simple way I can think of to do this is to use bsub's subshell interface: simply execute bsub <options> from your command line without specifying a command. bsub will then prompt you for a command in a subshell, and you can use quotes in this subshell.

Send the subshell an end-of-file (CTRL+D) to let it know you're done. Here's an example run using something similar to your case but running interactively instead of using -o to capture the output:

%  bsub -I
bsub> echo "foo;bar"
bsub>       <================[### Hit CTRL+D here ###]
Job <5841> is submitted to default queue <normal>.
<<Waiting for dispatch ...>>
<<Starting on hb05b10>>
foo;bar
%
Squirrel
  • 2,262
  • 2
  • 18
  • 29
  • Thanks @Squirrel. I ended up using bsub -Is bash to run interactive jobs, which is sort of similar I guess. – tospo Jun 07 '15 at 19:49
  • Sure, that'll work fine if you can run all your cases in the context of the same job. The phrasing of the question made it seem as though it was important to you that each case be a separate LSF job. – Squirrel Jun 08 '15 at 19:31