Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-07-2008, 02:01 AM   #1
LQ Newbie
Registered: Jul 2008
Posts: 8

Rep: Reputation: Disabled
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\" "

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

I appreciate any help

thank you!
Old 07-07-2008, 02:48 AM   #2
Registered: Jun 2008
Location: Toronto, Canada
Distribution: SuSE, RHEL, Mageia
Posts: 132

Rep: Reputation: 17
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"'
Old 07-07-2008, 03:02 AM   #3
Mr. C.
Senior Member
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
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.
Old 07-07-2008, 03:57 AM   #4
LQ Newbie
Registered: Jul 2008
Posts: 8

Original Poster
Rep: Reputation: Disabled
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"'
Old 07-07-2008, 04:00 AM   #5
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
Sorry, my posted solution didn't work.
So I removed it.

Last edited by jschiwal; 07-07-2008 at 04:10 AM.
Old 07-07-2008, 04:29 AM   #6
Mr. C.
Senior Member
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Review page 6 "Command Line Expansion Revisited", Week 10 Notes, Variables and Parameters,


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial commands via shell script bingo Programming 4 06-16-2007 12:19 AM
help with shell script commands Andrew0 Linux - Newbie 1 04-15-2006 12:55 PM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
Shell Script Commands shandy^^^ Programming 16 02-09-2006 10:16 AM
Commands/Shell script ?? paraiso Linux - Newbie 11 04-21-2005 10:58 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration