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! |
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"' |
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. |
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"' |
Sorry, my posted solution didn't work.
So I removed it. |
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. |