Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use the memory resource allocation command available in LSF. A normal format of the command is :

bsub -R "rusage [mem=1000]" sleep 100s

When I launch this command directly from terminal,it works. When i lsunch this command from a script, it fails.

Here is my script:

#! /bin/csh -f

set cktsim_memory = $1
set tmp = "|rusage [mem = $cktsim_memory]|" #method2
set tmp = `echo $tmp | sed 's/ =/=/g'` #method2
set tmp = `echo $tmp | sed 's/|/"/g' `
set bsub_option = ""
set bsub_option = ( "$bsub_option" "-R" "$tmp") #method2
set cmd = "bsub $bsub_option sleep 100s"
echo $cmd

Its run output is:

>./cktsim_memory_test 100
bsub_option -R "rusage [mem= 100]"
Bad resource requirement syntax. Job not submitted.
>bsub -R "rusage [mem= 100]" sleep 100s
Job <99775> is submitted to default queue <medium>.

As you can see in the terminal output above- when the bsub command launched from script, it fails, when the same command run from terminal it is ok...

Please help me debug the issue.

share|improve this question

Put your command in quotes with some slight modifications.

     bsub -q medium -R 'rusage[mem=1000 ]' 'cd ; ./run_command' 
     bsub -q medium -R 'rusage[mem=1000 ]' './FULL_PATH/run_command'

Note: - Make sure the "run_command" is accessible from your execution host

share|improve this answer
I don't think that is the issue, We can replace the run_command script with a simple sleep command and still the problem remains. – Ani May 17 '12 at 7:49
Please refer the question again, I have updated it. – Ani May 17 '12 at 7:49
Ahaa ! I had a similar experience with is your issue. Remove your double quotes with single. set cmd = "bsub $bsub_option sleep 100s" ==> set cmd = 'bsub $bsub_option sleep 100s'. I tested and it worked. Used "csh -x " to debug. – Chakri May 17 '12 at 13:48
Sorry its not REMOVE but REPLACE the double qoutes with single qoutes in your set cmd line. – Chakri May 17 '12 at 19:44
There seem to be a missing issue here : let a = 123 , echo "$a" gives 123, while echo '$a' gives $a , using single quotes will not interpret the variables. – Ani May 18 '12 at 3:15

This is the working code:

#! /bin/csh -f

set cktsim_memory = $1
set tmp = "'rusage [mem = $cktsim_memory]'" #method2
set tmp = `echo $tmp | sed 's/ =/=/g'` #method2

set bsub_option = ""
set bsub_option = ( "$bsub_option" "-R" "$tmp") #method2

set cmd = "bsub $bsub_option sleep 100s"
echo $cmd > lsfcmd ; source lsfcmd
share|improve this answer
Replacing double quotes with single at the last set line, as shown below worked. Here is working code. code. #! /bin/csh -f set cktsim_memory = $1 set tmp = "|rusage [mem = $cktsim_memory]|" #method2 set tmp = echo $tmp | sed 's/ =/=/g' #method2 set tmp = echo $tmp | sed 's/|/"/g' set bsub_option = "" set bsub_option = ( "$bsub_option" "-R" "$tmp") #method2 set cmd = 'bsub $bsub_option sleep 100s' echo $cmd $cmd – Chakri May 18 '12 at 16:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.