Register
It is currently Tue Sep 23, 2014 6:21 am

Command substitution issues


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Wed May 21, 2014 11:17 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Hi,

I have a script like so;

Code:
EMAIL='me@mycompany.com'
EMAILFROM="-e 'my_hdr From: Reporting server <no-reply@mycompany.com>'"
REPORT=game
OUTDIR=reports

echo "mutt -s \"Daily ${REPORT} report\" -a \"${OUTDIR}/${REPORT}.tsv\" ${EMAILFROM} -- ${EMAIL} < \"${OUTDIR}/message\""
mutt -s "Daily ${REPORT} report" -a "${OUTDIR}/${REPORT}.tsv" ${EMAILFROM} -- ${EMAIL} < "${OUTDIR}/message"


So when I run this I get;

Code:
$ ./reportscript.sh
mutt -s "Daily game report" -a "reports/game.tsv" -e 'my_hdr From: Reporting server <no-reply@mycompany.com>' -- me@mycompany.com < "reports/message"
Error in command line: invalid header field
Can't stat From:: No such file or directory
From:: unable to attach file.


If I copy/paste the mutt command the script echos into my terminal it works as expected.
The idea of having the MAILFROM variable include the -e switch is to make that optional without specifically detecting if it's required, which I could easily do but seems less...slick :)

This problem is less about resolving the issue (I can code around it) and more about understanding why it doesn't work as I expected :)

Many thanks,
Darth


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP