[wellylug] Problem with attachment

andrej at paradise.net.nz andrej at paradise.net.nz
Wed Mar 4 11:14:45 NZDT 2009


Quoting Peter Lynch <Peter.Lynch at acc.co.nz>:

> 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:
The encoding looks exactly like what I'd expect from uuencode, so
I don't think it's a failt with the process as such.  Maybe try
using mailx or mutt instead of mail, though, so you can produce proper
mime messages .... 

Something like:
#!/bin/bash
export maildate=`date --date=yesterday +'%h %e'`
sudo less /var/log/mail.log | grep "$maildate" > mail.txt
mailx -a  mail.txt -s "Mail log" xxx at xxx.co.nz


or:
#!/bin/bash
export maildate=`date --date=yesterday +'%h %e'`
sudo less /var/log/mail.log | grep "$maildate" > mail.txt
mailx -a  mail.txt -s "Mail log" xxx at xxx.co.nz



Cheers,
Andrej


P.S.: I hope there's not really a space between the shebang and the /bin/bash
in your actual script  ;)



More information about the wellylug mailing list