LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-07-2008, 03:01 AM   #1
wolfindark
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\" "
$SUBMIT

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

I appreciate any help

thank you!
 
Old 07-07-2008, 03:48 AM   #2
Vit77
Member
 
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, 04: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, 04:57 AM   #4
wolfindark
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, 05:00 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

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

Last edited by jschiwal; 07-07-2008 at 05:10 AM.
 
Old 07-07-2008, 05: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, http://cis68b1.mikecappella.com/
 
  


Reply


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 01:19 AM
help with shell script commands Andrew0 Linux - Newbie 1 04-15-2006 01:55 PM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 03:34 PM
Shell Script Commands shandy^^^ Programming 16 02-09-2006 11:16 AM
Commands/Shell script ?? paraiso Linux - Newbie 11 04-21-2005 11:58 AM


All times are GMT -5. The time now is 06:44 PM.

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