[plug] adding attachments

James Devenish devenish at guild.uwa.edu.au
Tue May 13 09:00:12 WST 2003


In message <1052786956.2090.280.camel at jlmpc>
on Tue, May 13, 2003 at 08:49:17AM +0800, Jon Miller wrote:
> I need to either add an attachment or pipe the results of a command to
> an email that is run via cron.

Cron will email the command's output to you. Say I have a programme
called `weather`, which writes the current weather report to a file
/etc/weather. My cron command could look like this:

* * * * * weather && cat /etc/weather
(or `weather; cat /etc/weather`, if I wanted the
contents unconditionally).

> will the following work:
> chkrootkit > | /bin/mail -s "ChkRootKit Results" jlmiller at mmtnetworks.com.au

Hopefully not (there is a typo). Lose the '>' before the pipe symbol
(unless you use a shell that  it -- most don't).

If chkrootkit dumps its output to the 'standard output', then you don't
can drop everything from the '>' onwards -- cron will mail the output to
you.

> Where I'm getting mixed up is if I pipe to a file (chkrootkit > crk.log)
> this puts  the info in the file, then I'll I'll need to attach this file
> to the email.

Try `chkrootkit | tee crk.log` instead.
(look at the man or info page for tee)

> Is there a mail command in using the command line to tell it to attach a
> file?

The mutt mailer can do attachments from the command line. Perhaps other
mailers can, too. If not, you may have to use MIME tools to construct a
raw mail message (but hopefully cat/tee will be sufficient).

-- 
James Devenish
UWA Student Guild IT Officer
<mailto:it at guild.uwa.edu.au> <http://www.guild.uwa.edu.au/>



More information about the plug mailing list