Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
$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
add comment

2 Answers 2

Put your command in quotes with some slight modifications.

     bsub -q medium -R 'rusage[mem=1000 ]' 'cd ; ./run_command' 
     -or-
     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 quotes..here 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
show 1 more comment

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
add comment

Your Answer

 
discard

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.