LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 05-30-2008, 07:40 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
Avoiding Shell Script Brace Expansion


I'm trying to run a single conky command from within a shell script. The following line works fine when run directly from the command line:

conky -t '${color green}/dev/sdd Temp:${color white} ${hddtemp /dev/sdd}' -x 290 -y 290

Of course, from within a shell script the shell interpreter sees the braces and applies brace expansion. I have tried to enclose the braces with single quotation marks, or preceded by a backslash, but the command always fails.

I would be grateful for some help.

Thanks again.
 
Old 05-30-2008, 07:51 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
As far as I know, a bash command follows the same rules in a terminal and in a script. In your example the single quotes should stop the shell from interpreting the contents in either case.

How does the command fail, and how do you know that it involves "brace expansion"?
 
Old 05-30-2008, 07:51 PM   #3
grizly
Member
 
Registered: Nov 2006
Location: Melbourne Australia
Distribution: Centos, RHEL, Debian, Ubuntu, Mint
Posts: 128

Rep: Reputation: 16
Try different shells..

#!/bin/bash
#!/bin/tsch
#!/bin/csh
#!/bin/ksh

there has to be one that does what you want..

Try using the same shell as your command line, as you say it works that way.
 
Old 05-30-2008, 08:36 PM   #4
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
Oops, I forgot to add that in my script I actually was using a variable for /dev/sdd....

Quote:
In your example the single quotes should stop the shell from interpreting the contents in either case.
Well....crap.

Based upon your statement I tried again.

I finally realized I could use multiple sets of quotation marks.

This finally succeeded:

conky -t '${color green}'$BACKUPDISK' Temp:${color white} ${hddtemp '$BACKUPDISK'}' -x 290 -y 290

Oh well, I hope this helps future readers of this thread!

Thanks for the clue that helped me!
 
Old 05-31-2008, 09:36 AM   #5
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
We just had an old sed post revived concerning this very same thing.
 
  


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
bash: extra stuff in brace expansion jhwilliams Programming 4 09-07-2007 02:44 AM
Variable expansion inside of a bash script! A.S.Q. Linux - Newbie 4 09-29-2006 09:09 AM
bash shell command line expansion hansi umayangan Linux - General 2 03-13-2005 11:31 AM
Bash Script Expansion Problem meadensi Linux - Newbie 1 03-04-2005 05:17 PM
bash script $n variable expansion cortez Programming 6 12-08-2003 04:03 PM


All times are GMT -5. The time now is 12:11 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration