I am trying to send an email with two attachments . I have tried all previous suggestion in this forum but none worked. I could send one attachment in an email by
but unable to send multiple attachments .
I have tried
1 . `(uuencode $file1 $file1 ; uuencode $file2 $file2)` | mailx -m -s "All Files" xxx@xxx.com
2.
files= ( "$file1" "$file2" )
for fileName in ${files[@]}
do
uuencode $fileName $fileName
done)` | mailx -m -s "files in attachment" xxx@xx.com
By using 1 , I am getting message that begin : not found .
By 2 , I am getting message that the file could not be found , but I see that the file exists in the path.
I am very confused after trying a lot. Please help
Thanks a lot it worked : )
Actually I put the backticks here because previously I got messages that '(' was not expected which was fixed if I put a backTick. So i developed habit of backtick before bracket thinking that my version of linux does not recognize brackets.
It probably meant something else by that error. Perhaps you were trying to use arrays in a shell that didn't support them. It depends more on the shell than the OS.
It is painful when someone cannot post the version of HP-UX (which appears clearly in uname -a ).
Anyway, assuming that this is a modern version, /sbin/sh will be the Posix Shell.
Corona688 has hit the nail on the head. The solution posted largely fits the bill.
There are differences between unix and MSDOS text file formats. I would convert the files if the mail reader is likely to be a Microsoft mail client.
The only change I might make is to ensure the the names of the files in $file1 and $file2 are formatted to MSDOS standards. e.g. If the file is a Text file it should have the extension ".txt" such that the recipient can open the file with Windows Notepad.
Normally MSDOS File Extensions are totally irrelevant in unix, but in email attachments they are important.
Ps. Your Option 2 is a non-starter. It contains too many syntax errors.
Have you tried this variation (some licence taken on the output format):
The only real difference is that the email body should appear before the attachments.