- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How to send multiple files as an attachment in sin...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2017 05:07 AM
07-03-2017 05:07 AM
Hi,
We want to send multiple files as an attachment in single mail through SUSE Linux Script. But looks like there is no "m" option in SUSE Linux..
Please find the script which we are using in HP-UX as below but same is not working in SUSE Linux
TEMPFILE=/tmp/temp$RANDOM
if [ -a $TEMPFILE ]
then
rm $TEMPFILE
fi
FOLDERNAME=/logs
cd $FOLDERNAME
for file in `ls`
do
cat $file | ux2dos | uuencode $file >> $TEMPFILE
done
cat $TEMPFILE | mailx -m -s "Subject`hostname`" narendra.uttekar@xyz.com
rm $TEMPFILE
Thanks,
Narendra
Solved! Go to Solution.
- Tags:
- attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2017 11:14 PM
07-04-2017 11:14 PM
Re: How to send multiple files as an attachment in single mail through SUSE Linux Script
> We want to send multiple files as an attachment [...]
Do you want to send multiple files as _an_ attachment, or multiple
files as _multiple_ attachments (in one message)?
Programs like Info-ZIP Zip or "tar" (usually used with gzip or bzip2
(or similar programs) for compression) can be used to package multiple
files into one, and then one attachment can carry the whole collection.
If you want multiple attachments in one message, then you should
probably look for a real MIME e-mail client program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2017 02:21 AM
07-05-2017 02:21 AM
SolutionThe -m option in HP-UX is described in the HP-UX mailx(1) man page as:
-m Do not add MIME header lines Mime Version, Content Type & Content Encoding to the header
information while sending mails.
Your script is using a legacy method of sending email attachments: the MIME standard for handling different character sets, attachments and other modern email features has existed since year 1993.
At least on a SuSE SLES 12 SP2 system I had available to me for testing, the SuSE mailx command always adds the MIME header lines and cannot be prevented from adding them. On the other hand, it has option -a for attaching files to messages.
The script is also using "ux2dos" which does not exist in SuSE: the equivalent would be "unix2dos".
Let me suggest an alternative script for you:
#!/bin/sh # script settings here FOLDERNAME=/logs
# create a list of "-a <filename>" options for SuSE mailx cd "$FOLDERNAME" for LOGFILE in * do ATTACHMENTS="$ATTACHMENTS -a $LOGFILE" done mailx $ATTACHMENTS -s "Subject $(hostname)" narendra.uttekar@xyz.com
Using the MIME attachments instead of legacy uuencoding allows the attachments to be opened successfully in both Windows and Unix/Linux systems alike: SuSE mailx is smart enough to detect that the files you're attaching are text files, so it automatically uses the text/plain MIME type to attach them. Then, the receiving email program can automatically convert the line endings if necessary for the destination system, just like it already does for the regular email text, so running the attachments through unix2dos should no longer be necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2017 07:15 AM
07-05-2017 07:15 AM
Re: How to send multiple files as an attachment in single mail through SUSE Linux Script
> [...] so running the attachments through unix2dos should no longer be
> necessary.
Info-ZIP Zip and UnZip also offer options to adjust line endings
(Zip: -l, -ll; UnZip: -a, -aa), so you could probably shed
ux2dos/unix2dos with that method, too.
As usual, many things are possible, and it may help to begin with
your actual requirements, rather than asking how to implement a
particular "solution" to a problem.