Jump to content

mail script help


Guest anon
 Share

Recommended Posts

Trying to run a script to email me but it fails, any ideas on what im doing wrong here? This is the line that causes the problem:

sed -e 's/$/\n/g' tmp.txt | exim  "Test  Report"  anon@somedomain

This is the error i get;

A message that you sent contained a recipient address that was incorrectly constructed:

Test Report  missing or malformed local part (expected word or "<")

Link to comment
Share on other sites

maybe should be

"Chris The drunken english geek <anon@somedomain>"

Damit that works Paul. :thanks:

 

For anyone thats interested, there's app called logwatch that e-mails you reports from /var/log but it seems to only run on redhat fedora etc. There is no version for MDK. This script takes some interesting tit bits from the logs and e-mails them to you.

 #! /bin/bash
rm -f tmp.txt
touch tmp.txt

echo "***Uptime***" >> tmp.txt
uptime >> tmp.txt

echo "***Disk Usage Report***" >> tmp.txt
df >> tmp.txt
echo "" >> tmp.txt

theDate=`date +'%b %e'`
echo "***Auth Log Report for $theDate***" >> tmp.txt
echo "" >> tmp.txt
echo "Failed Attempts:" >> tmp.txt
echo "______________________________________________" >> tmp.txt
grep "$theDate.*\(failure\|Failed\|Illegal\)" /var/log/auth.log >> tmp.txt
echo "" >> tmp.txt
echo "" >> tmp.txt
echo "Successful Logins:" >> tmp.txt
echo "______________________________________________" >> tmp.txt
grep "$theDate.*Accepted" /var/log/auth.log >> tmp.txt

echo "" >> tmp.txt
echo "***Last Logins***" >> tmp.txt
last >> tmp.txt
echo "" >> tmp.txt

echo "" >> tmp.txt
echo "***Messages***" >> tmp.txt
grep "$theDate"  /var/log/messages >> tmp.txt
echo ""

echo "" >> tmp.txt
echo "***Processes Running***" >> tmp.txt
ps aux >> tmp.txt
echo "" >> tmp.txt

sed -e 's/$/\n/g' tmp.txt | mail -s "Server Report" username@domain.tld

rm -f tmp.txt

You will need to edit the last but one line for your mail program, and also Pauls corection for the email address format.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...