Results 1 to 6 of 6
Hi im struggling to get a script sample, i need the script to do the following:
It needs to search a log file
then if the word searched is found ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-27-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 4
Script To search a log and mail if word is not found
Hi im struggling to get a script sample, i need the script to do the following:
It needs to search a log file
then if the word searched is found it must do nothing
otherwise it needs to mail to a address if it is not found
Please guys this is Urgent.
I really need help on this
thanx in advance hope if this is solved that it will help alot of poeple
Kind Regards to all you linux fans
- 06-27-2011 #2Just Joined!
- Join Date
- Jan 2008
- Posts
- 21
I can't help you with the script, but I can tell you that emailing can be problematic. Check out a service called SendGrid, which is free if you send < 100 messages per day. I use blat to shoot the messages to them under Windows; you'll need a similar command (sorry, have no idea what) to do the same.
Hope this helps!
I.
- 06-28-2011 #3Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
in sh or bash using mail for mailer
Code:x=`grep -c word logfilename if [ x -eq 0 ] then echo "email text" | mail -s subject receiver@domain fi
- 06-28-2011 #4Just Joined!
- Join Date
- Jun 2011
- Posts
- 4
Thanks Will try this thanx for the reply
- 06-28-2011 #5Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
There is a missing backtick on the first line. Should be:
Code:x=`grep -c word logfilename`
- 06-28-2011 #6Just Joined!
- Join Date
- Jun 2011
- Posts
- 4
Thank you very much "digitalamish" & "ibexslam"
Hi I ended up figuring something else out i'll post it here and hope it helps alot of you guys
Thanx for the mail thread needed that pipe option
#!/bin/bash
grep "grep value" /destination/file.log -c > name.txt
new=`cat name.txt`
old=`cat name.old.txt`
echo "$new"
echo "$old"
if [ $old -lt $new ]
then
echo continue
else
echo error
echo "body" | mailx -s "subject" user@domain user@domain.com
fi
mv -f pop.txt pop.old.txt


1Likes
Reply With Quote
