How to write a script to send these alerts?

Hello AIXians :slight_smile:

I want to complete this task using a script.

The task is:
We have a file called (alerts.log), this file is receiving all new alerts from ORACLE application all the day, I want to send email to a specific mail address when this file receives all alerts that starts with (ORA-).

Is the idea clear?
Please help me to finish this task.

Many thanks

---------- Post updated 10-29-13 at 12:10 AM ---------- Previous update was 10-28-13 at 10:20 PM ----------

Dear AIXians,
I know how to send mails from AIX, but the problem now, how to tell the script to send the new notification when the file (alerts.log) receives new alerts that have the word (ORA-) in the beginning of each line.

How about:

tail -f alerts.log | 
while read line
do
  case $line in 
    (ORA-*) echo "send a mail about: $line"
  esac
done

Great Scrutinizer.
It seems good, but I have a problem with the 5th line.

Why?!
Because I already have a tool to send emails from AIX, the tools needs only the (destination email address) and (subject of the mail) and (the content of the mail)

So how can I carry the contents of (ORA-*) alert, to this tool?

Hi, the echo statement is only a placeholder to show the principle. You can replace the echo statement with your tool and "$line" will contain the line that needs to be reported on...

Thanks Mr. Scrutinizer.
What if I want to put this line to a new file?
So each new line starts with (ORA-) will added to the new file, called (out.txt) for example.

Hi, just add a redirection after done :

done > out.txt
1 Like