LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   commands in shell script ? (https://www.linuxquestions.org/questions/linux-newbie-8/commands-in-shell-script-654016/)

wolfindark 07-07-2008 02:01 AM

commands in shell script ?
 
Dear Friends,

I am trying to execute this command in bash script. the command is :
bsub -k "$RES_DIR 10 method=fluent" -q flu -n 4 -J $JOB_NAME -W 180 "fluent $2 -gu -driver null -t4 -i $JOUR > $JOUR.out"

If I put it in script like above, it is working. However if I write it as following:
SUBMIT="bsub -k \"$RES_DIR 10 method=fluent\" -q flu -n 4 -J $JOB_NAME -W 180 \"fluent $2 -gu -driver null -t4 -i $JOUR > $JOUR.out\" "
$SUBMIT

it does not work. I checked SUBMIT by echo $SUBMIT it gives correct command.

I appreciate any help

thank you!

Vit77 07-07-2008 02:48 AM

Try to insert backslash before the $ signs
OR use single quote chars around your command:

SUBMIT='bsub -k "$RES_DIR 10 method=fluent" -q flu -n 4 -J $JOB_NAME -W 180 "fluent $2 -gu -driver null -t4 -i $JOUR > $JOUR.out"'

Mr. C. 07-07-2008 03:02 AM

echo will not show you where word boundaries are; it can be deceiving and is not the right tool when trying to determine what is wrong with quoting.

Add :

set -x

before your variable assignment to see what the shell sees, and then carefully examine the output.

wolfindark 07-07-2008 03:57 AM

After set -x, it gives this output. first is the assignment, second is $SUBMIT. single quotes are appearing in the command. Does shell see all as a separate command ? what is the problem do you think?

+ SUBMIT=bsub -k "restart 10 method=fluent" -q flu -n 4 -J nozz -W 180 "fluent 2ddp -gu -driver null -t4 -i run-case.jou > run-case.jou.out"

+ bsub -k '"restart' 10 'method=fluent"' -q flu -n 4 -J nozz -W 180 '"fluent' 2ddp -gu -driver null -t4 -i run-case.jou '>' 'run-case.jou.out"'

jschiwal 07-07-2008 04:00 AM

Sorry, my posted solution didn't work.
So I removed it.

Mr. C. 07-07-2008 04:29 AM

Review page 6 "Command Line Expansion Revisited", Week 10 Notes, Variables and Parameters, http://cis68b1.mikecappella.com/


All times are GMT -5. The time now is 09:10 AM.