I am trying to attach multiple files using mutt command, and all file names to be attached are taken from a flat file. and mutt command is called from a bash script when :
Sometimes code is executed appropriately and attachments are seen in the email whereas sometimes email is received without attachments and attachmens' file path are seen as broken string in as :
From : jboss@172.19.10.55
To : -@172.19.10.55;/home/j@172.19.10.55;oss/t@172.19.10.55;mp/a.html@172.19.10.55;
---------- Post updated at 12:55 PM ---------- Previous update was at 11:09 AM ----------
Not sure what's going wrong. Above solution works independently when run as a stand-alone command , but when run from within the script, it fails and no attachments are seen in the email. What we get is as mentioned above.
Any solution please........
---------- Post updated at 03:45 PM ---------- Previous update was at 12:55 PM ----------
It works when we change the order of mutt switches, i.e. put attachments at last.
Maybe someone is gobbling up the -- or something like that. In some situations, the shell quotes together the subshell output, so passing it through a variable or function call may be needed to break it up. You can put a "truss/strace/tusc -fae -o /tmp/mutt.$$.tr" prefix on mutt in the shell script and see in detail what the actual call is like. Putting the attachment list last is a nice workaround, though.
The workaround of putting attachments list at last does not work always. There is something that breaks the attachments and appends ip to broken substrings but not sure what
---------- Post updated 02-06-13 at 12:21 PM ---------- Previous update was 02-05-13 at 06:08 PM ----------
Issue found.
We know default IFS for bash shell is " " [[SPACE].
Hence while above script tries to read the attachments, for some reason string is broken.
So we can update script to set temperory IFS to "\n" while the attachment files are being read in a for loop and then set original IFS state.