I'm not too fluent at this and having problems comprehending / coming up with a way to do it. Our telephone system is spitting out call information on it's maintenance (serial) port which i have connected to a linux box. I want to be able to monitor the output of this text and when a 911 call is dialed an email is sent out notifying people of specific information.
I currently have ttyS0 sending all output to call.log. A simiple "tail -f call.log" will display all output in real time which i want to analyze.
The text file will contain chunks of text that will look like this:
Quote:
ERR225 0 2
OSN000 CUST 0 911 CALL ALERT
TIME: 13:24:36 NOV 14, 2012
NAME: John Doe
ORIG DN: 6606
LOC: UNKNOWN
DES: ROOM 362
SET: IP SET
TER RTMB: 13-42 ACOD: 886
CALLED#: 911
CALLING#: 5555555
OSN000 RECORD END
ERR225 0 2
ERR225 0 2
DTC001
I want to be able to read the logfile realtime (tail -f) and create an email whenever 911 is dialed with specific information from above.
The text "911 CALL ALERT" will always exist as a way to indicate the start of an alert, and it will always end with "RECORD END". The middle text between those two events are key.
Out of the chunk of data above I want to be able to parse out the following information to put into an email:
-TIME:
-NAME:
-ORIG DN:
-DES:
What tools should i use to do this? awk?