troubleshooting Question

Easy REGEXP question #2

Avatar of gswitz
gswitz asked on
Unix OSLinuxRegular Expressions
4 Comments1 Solution412 ViewsLast Modified:
I am applying this regexp pattern
File Not Found|LRM\-|Error|Ora\-|SP2\-|FAIL|RC\s*=\s*-?[123456789]+

to look for errors in a log using this function...

Send_Mail_OnError()
{
  #For each line in regex_patterns.txt file,
  #the regular expression-like will fire on the file $error_log
  #if any line returns true, then we will step into the if...
  #Be advised!! Passing a null value in $error_log causes an indefinite hang.
  if egrep -i -s -f $root_dir/regex_patterns.txt $error_log; then
    #For each email address in $emaillist, send and email...
    Send_Mail
  fi
}

This works well for all cases except a single job which sometimes returns the following two lines within the file...

0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.

So I think I want to use the results from an exclusionary egrep call first... maybe something like this...


Send_Mail_OnError()
{
  #For each line in regex_patterns.txt file,
  #the regular expression-like will fire on the file $error_log
  #if any line returns true, then we will step into the if...
  #Be advised!! Passing a null value in $error_log causes an indefinite hang.
  if egrep -i -s -f $root_dir/regex_patterns.txt [egrep -v '0 Rows not loaded due to data errors\.|0 Rows not loaded because all WHEN clauses were failed\.' $error_log]; then
    #For each email address in $emaillist, send and email...
    Send_Mail
  fi
}

Could someone help me with this syntax? Am I on the right track?

Thanks!!

G
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros