Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Unhappy 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

  2. #2
    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!


  3. #3
    in sh or bash using mail for mailer

    x=`grep -c word logfilename
    if [ x -eq 0 ]
    echo "email text" | mail -s subject receiver@domain

  4. $spacer_open
  5. #4
    Thanks Will try this thanx for the reply

  6. #5
    There is a missing backtick on the first line. Should be:

    x=`grep -c word logfilename`

  7. #6

    Thumbs up 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


    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 ]
    echo continue
    echo error

    echo "body" | mailx -s "subject" user@domain


    mv -f pop.txt pop.old.txt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts