I'm trying to send mail using Mailx and uuencode with attachments using the following in a shellscript
attachments=uuencode file1 file1;uuencode file2 file2;
(echo BODY ; $attachments )| mailx -s "Attachments" -m someone@mail.com
For the above script only mail without attachment is sent,However when i use the following
(echo BODY ; uuencode file1 file1;uuencode file2 file2;)| mailx -s "Attachments" -m someone@mail.com
Now mail is sent with the attachments.
I'm fairly new shellscripting kindly help.
You are using the wrong quotes for command substitution:
attachments=`uuencode file1 file1;uuencode file2 file2`
or better
attachments=$( uuencode file1 file1;uuencode file2 file2 )
See the Command Substitution section of the bash man page
And then use echo
to output the variable content
(echo BODY ; echo $attachments )| mailx -s "Attachments" -m someone@example.com
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.