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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...