How to error script for a log file?

So, I have a log file I need to search for ORA- errors.

If the only errors are: ORA-39082|ORA-39083|ORA-01917 then the script should have executed okay.

If there are ORA- errors that are in the log file other than above, then I need to send a mail saying that the script failed.

Any ideas with you awk experts on maybe how to do this?

You could use egrep like this:

egrep -o 'ORA-\S+' logfile |
egrep -qv '(39082|39083|01917)' && mail -s "The script failed" cougartrace@your.email.address <<EOF
Body of the email
message
EOF

---------- Post updated at 07:31 AM ---------- Previous update was at 07:01 AM ----------

and using awk:

awk '/ORA-/ { while(match($0, "ORA-\\S+")) {
    if(substr($0,RSTART,RLENGTH) !~ "(ORA-39082|ORA-39083|ORA-01917)")
        exit 1
    $0=substr($0,RSTART+RLENGTH)}}' logfile || mail ...