Command substitution issues
Page 1 of 1

Author:  DarthWavy [ Wed May 21, 2014 11:17 am ]
Post subject:  Command substitution issues


I have a script like so;

EMAIL='[email protected]'
EMAILFROM="-e 'my_hdr From: Reporting server <[email protected]>'"

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;

$ ./
mutt -s "Daily game report" -a "reports/game.tsv" -e 'my_hdr From: Reporting server <[email protected]>' -- [email protected] < "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,

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group •