gswitz
asked on
Easy REGEXP question #2
I am applying this regexp pattern
File Not Found|LRM\-|Error|Ora\-|SP 2\-|FAIL|R C\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.t xt $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.t xt [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
File Not Found|LRM\-|Error|Ora\-|SP
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.t
#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.t
#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
Sorry for needing hand holding...
Could you give me the exact syntax based in my posted code?
Could you give me the exact syntax based in my posted code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works like a charm! Thanks!!
Open in new window