The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to search multiple strings in a file deepakpv Shell Programming and Scripting 2 09-19-2008 03:02 AM
how to search with 2 strings. syamkp Shell Programming and Scripting 2 03-10-2008 04:50 AM
Problem to search multiple strings sudhish Shell Programming and Scripting 2 10-25-2007 02:00 PM
Search between strings with an OR pbsrinivas Shell Programming and Scripting 3 07-12-2007 04:46 AM
Search for strings lesstjm UNIX for Dummies Questions & Answers 5 04-26-2002 09:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-04-2009
AnneAnne AnneAnne is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 9
Question Search for multiple strings and mail accordingly

Hi,
I need to find if there is any error in the last few lines of the log file and send a mail accordingly.For example,
Following errors can be logged in the log file.
ERR_1="DB Connection not established"
ERR_2="Server Unloading"
I need to find if these errors are found in the log file and send different mails according to the errors.
How can we do that?
  #2 (permalink)  
Old 03-05-2009
quirkasaurus's Avatar
quirkasaurus quirkasaurus is offline
Registered User
  
 

Join Date: Jan 2009
Location: canton, michigan
Posts: 373
Code:
#!/bin/ksh

cat log |
while read line; do

  case $line in

  ERR_1*) echo $line | mailx to_somebody@wherever.com ;;
  ERR_2*) echo $line | mailx to_somebody_else@wherever.com ;;

  esac

done
  #3 (permalink)  
Old 03-12-2009
AnneAnne AnneAnne is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 9
It works..U r brilliant!!
Thanks
  #4 (permalink)  
Old 03-12-2009
quirkasaurus's Avatar
quirkasaurus quirkasaurus is offline
Registered User
  
 

Join Date: Jan 2009
Location: canton, michigan
Posts: 373
Quote:
Originally Posted by AnneAnne View Post
It works..U r brilliant!!
Thanks
You're welcome!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0