automation, monitoring, scripting, Uncategorized

How to send attachment from Linux

There are some cases when its needed to send via email many scripts output results from Linux command line.  Here is an working example to achieve this.

It is expected that email options have been already configured so that mail command is working.

Below is the example of command which will zip all related logs  from /tmp folder into a .zip file “WLCs_logs.zip”

zip -r /tmp/WLCs_logs.zip /tmp/WLCs-peers-*.log.filtered

next command will send email with .zip attachment to me@mymail.com

mpack -s “AVC and other data from WLCs” /tmp/WLCs_logs.zip me@mymail.com

Mentioned commands can be executed from cron on a regular basis.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s