LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-24-2010, 08:40 PM   #1
nixlearn
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Rep: Reputation: 0
Bash Variable within variable not being interpreted?


Hello all I am working on the following gibberish script and can't seem to get the $SUBJECT variable to expand during emailing. I attempted to turn the subject into a variable and instead of printing the subject mutt is emailing this email to all words in the subject line.

CANDY=gummy_worm
BREAD=italian
RECIPIENT=someguy@aol.com
OUTPUTDIR=/tmp/somedir

SUBJECT="This was the $CANDY for the baker, he also likes $BREAD"

ARRAY_OF_WORDS=(one two three four)

# Scan loop starts here.

for word in ${ARRAY_OF_WORDS[*]}
do
touch $OUTPUTDIR/"$word"_"$CANDY".html
$MUTTCMD -s $SUBJECT -a somefile.txt $RECIPIENT < /tmp/testmsg.txt >> /dev/null 2>&1
done


I tried enclosing $SUBJECT within single quotes but that do that the variable is not interpreted. Any advice would be great.

Thanks
 
Old 02-24-2010, 08:58 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Try double quotes:

Code:
$MUTTCMD -s "$SUBJECT" -a somefile.txt $RECIPIENT < /tmp/testmsg.txt >> /dev/null 2>&1
 
Old 02-24-2010, 09:23 PM   #3
nixlearn
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Worked!

Thank you kbp, was banging my head on this for a while...

Thank you for the fast response.
 
  


Reply



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: HISTSIZE: readonly variable -bash: HISTFILESIZE: readonly variable deathsfriend99 Linux - Newbie 4 12-08-2009 12:51 PM
How to get variable from text file into Bash variable mcdef Linux - Software 2 06-10-2009 01:15 PM
Problem with bash script - variable name within variable name steven.c.banks Linux - Newbie 3 03-10-2009 03:08 AM
bash scripting need help getting a variable of a variable dovo Programming 6 10-29-2008 01:30 PM
Line breaks aren't interpreted when defining a variable spiffytech Linux - Software 4 12-27-2005 03:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:50 AM.

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
Open Source Consulting | Domain Registration