[wellylug] Problem with attachment

Daniel Pittman daniel at rimspace.net
Wed Mar 4 13:09:23 NZDT 2009


"Peter Lynch" <Peter.Lynch at acc.co.nz> writes:

> I have the following script which runs daily on my Debian Lenny server.
>
> #! /bin/bash
> export maildate=`date --date=yesterday +'%h %e'`
> sudo less /var/log/mail.log | grep "$maildate" > mail.txt
> uuencode mail.txt mail.txt | mail -s "Mail log" xxx at xxx.co.nz
>
> When I view the mail through SquirrelMail (version 1.4.15), it does not
> recognise the file as being an attachment.  It simply displays this:

Others pointed out where the issue is here, with uuencoded content not
being identified.

I wanted, instead, to suggest a better strategy for solving your
problem, so you don't have to write all this yourself.

The first solution is to replace the grep, etc, occurrence:
You could simply email /var/log/mail.log.1 each morning, after the daily
maintenance scripts have run.

That will send you all the content, without dropping the few hours that
your current script does, more reliably and with a much lower overhead.


Another solution is to use a tool like 'logcheck', packaged, which is
designed to read your system logs and email you the interesting parts.

That would save you manually filtering the boring parts of the mail log,
as well as handling the reading, emailing and so forth for you.


Finally, you might want to look at a log summary tool; since you didn't
specify the MTA I don't suggest any specific tool, but rather that there
are plenty of options that will read your logfile and report statistics
and problems to you.

Regards,
        Daniel



More information about the wellylug mailing list