Sponsored Content
Top Forums Shell Programming and Scripting Read Log Realtime and Parse out Information for a Report Post 302731683 by Pythong on Thursday 15th of November 2012 02:07:29 PM
Old 11-15-2012
Read Log Realtime and Parse out Information for a Report

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?
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Information for Report

As part of my A+ certification class I was asked to create a webpage on operating systems other than windows, in specific Linux, Mac, and Unix. I got Linux and Mac done but I am having trouble finding specific information on Unix. I keep being directed to Linux or Mac. Can anyone help. In specific... (1 Reply)
Discussion started by: Shinjin
1 Replies

2. Shell Programming and Scripting

Trying to Parse Version Information from Text File

I have a file name version.properties with the following data: major.version=14 minor.version=234 I'm trying to write a grep expression to only put "14" to stdout. The following is not working. grep "major.version=(+)" version.properties What am I doing wrong? (6 Replies)
Discussion started by: obfunkhouser
6 Replies

3. Shell Programming and Scripting

Bash Script to read a file and parse each record

Hi Guys, I am new to unix scripting and I am tasked to parse through a CSV file delimited by #. Sample: sample.csv H#A#B#C D#A#B#C T#A#B#C H = Header D = Detail Record T = Tail What I need is to read the file and parse through it to get the columns. I have no idea on how... (8 Replies)
Discussion started by: 3vilwyatt
8 Replies

4. Shell Programming and Scripting

Help w/ script to read file and parse log message

Hi, I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***... The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE. Can anyone give help? Thanks (2 Replies)
Discussion started by: shyork2001
2 Replies

5. Programming

How to read BGP session information with C

Friends, I want to read BGP session information with C ( in FreeBSD ). The program will almost work like a sniffer. My FreeBSD box (which is not a BGP speaker) will look at BGP session information (after catching and parsing it) and take a decision based on the information it sees. :wall: ... (1 Reply)
Discussion started by: asadfx
1 Replies

6. AIX

read lv mountpoint information directly from disk

Hello, I need to get the lv mountpoint from the hdisk directly (from vgda i guess) and not from odm or /etc/filesystems I knew the command, but unfortunately I forgot it ;) cheers funksen (5 Replies)
Discussion started by: funksen
5 Replies

7. Shell Programming and Scripting

Extract/Parse information from html (website)

Hello, I want to extract some informations from a html (website, http://www.energiecontracting.de/7-mitglieder/von-A-Z.php?a_z=B&seite=2 ) file and save those in a predefined format (.csv).. However it seems that the code on that website is kinda messy and I can't find a way to handle it... (5 Replies)
Discussion started by: TehOne
5 Replies

8. Shell Programming and Scripting

Python Binary File Read and Parse

Hi to everyone :), i have a challenge right now in python that for now needs a bit of help in one part of the c0de. The task is create a new file with the name of the file defined by the ASCII content between the 3 byte and the 16 byte that is parsed from the binary file, the file is over 20 Mb i... (0 Replies)
Discussion started by: drd0spt
0 Replies

9. Shell Programming and Scripting

awk script to parse case with information in two fields of file

The below awk parser works for most data inputs, but I am having trouble with the last one. The problem is in the below rules steps 1 and 2 come from $2 (NC_000013.10:g.20763686_20763687delinsA) and steps 3 and 4 come from $1 (NM_004004.5:c.34_35delGGinsT). Parse Rules: The header is... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. UNIX for Advanced & Expert Users

Script to parse and compare information in two fields of file

Hello, I am working parsing a large input file1(field CFA) I have to compare the the file1 field(CFA byte 88-96) with the content of the file2(It contains only one field) and and insert rows equal in another file. Here is my code and sample input file: ... (7 Replies)
Discussion started by: GERMANOS
7 Replies
Log::Report::Dispatcher::Try(3pm)			User Contributed Perl Documentation			 Log::Report::Dispatcher::Try(3pm)

NAME
Log::Report::Dispatcher::Try - capture all reports as exceptions INHERITANCE
Log::Report::Dispatcher::Try is a Log::Report::Dispatcher SYNOPSIS
try { ... }; # mind the ';' !! if($@) { # signals something went wrong if(try {...}) { # block ended normally my $x = try { read_temperature() }; my @x = try { read_lines_from_file() }; try { ... } # no comma!! mode => 'DEBUG', accept => 'ERROR-'; try sub { ... }, # with comma mode => 'DEBUG', accept => 'ALL'; try &myhandler, accept => 'ERROR-'; print ref $@; # Log::Report::Dispatcher::Try $@->reportFatal; # re-dispatch result of try block $@->reportAll; # ... also warnings etc if($@) {...} # if errors if($@->failed) { # same # } if($@->success) { # no errors # } try { # something causes an error report, which is caught report {to => 'stderr'}, FAILURE => 'no network'; }; $@->reportFatal(to => 'syslog'); # overrule destination print $@->exceptions; # no re-cast, just print DESCRIPTION
The Log::Report::try() catches errors in the block (CODE reference) which is just following the function name. All dispatchers are temporarily disabled by "try", and messages which are reported are collected within a temporary dispatcher named "try". When the CODE has run, that "try" dispatcher is returned in $@, and all original dispatchers reinstated. Then, after the "try" has finished, the routine which used the "try" should decide what to do with the collected reports. These reports are collected as Log::Report::Exception objects. They can be ignored, or thrown to a higher level try... causing an exit of the program if there is none. METHODS
Constructors $obj->close Only when initiated with a FILENAME, the file will be closed. In any other case, nothing will be done. Log::Report::Dispatcher::Try->new(TYPE, NAME, OPTIONS) -Option --Defined in --Default accept Log::Report::Dispatcher depend on mode charset Log::Report::Dispatcher <undef> died undef exceptions [] format_reason Log::Report::Dispatcher 'LOWERCASE' locale Log::Report::Dispatcher <system locale> mode Log::Report::Dispatcher 'NORMAL' accept => REASONS charset => CHARSET died => STRING The exit string ($@) of the eval'ed block. exceptions => ARRAY-of-EXCEPTIONS format_reason => 'UPPERCASE'|'LOWERCASE'|'UCFIRST'|'IGNORE'|CODE locale => LOCALE mode => 'NORMAL'|'VERBOSE'|'ASSERT'|'DEBUG'|0..3 Accessors $obj->died([STRING]) The message which was reported by "eval", which is used internally to catch problems in the try block. $obj->exceptions Returns all collected "Log::Report::Exceptions". The last of them may be a fatal one. The other are non-fatal. $obj->isDisabled See "Accessors" in Log::Report::Dispatcher $obj->mode See "Accessors" in Log::Report::Dispatcher $obj->name See "Accessors" in Log::Report::Dispatcher $obj->needs See "Accessors" in Log::Report::Dispatcher $obj->type See "Accessors" in Log::Report::Dispatcher Logging $obj->collectLocation Log::Report::Dispatcher::Try->collectLocation See "Logging" in Log::Report::Dispatcher $obj->collectStack([MAXDEPTH]) Log::Report::Dispatcher::Try->collectStack([MAXDEPTH]) See "Logging" in Log::Report::Dispatcher $obj->log(OPTS, REASON, MESSAGE) Other dispatchers translate the message here, and make it leave the program. However, messages in a "try" block are only captured in an intermediate layer: they may never be presented to an end-users. And for sure, we do not know the language yet. The MESSAGE is either a STRING or a Log::Report::Message. $obj->reportAll(OPTIONS) Re-cast the messages in all collect exceptions into the defined dispatchers, which were disabled during the try block. The OPTIONS will end-up as HASH-of-OPTIONS to Log::Report::report(); see Log::Report::Exception::throw() which does the job. $obj->reportFatal Re-cast only the fatal message to the defined dispatchers. If the block was left without problems, then nothing will be done. The OPTIONS will end-up as HASH-of-OPTIONS to Log::Report::report(); see Log::Report::Exception::throw() which does the job. $obj->stackTraceLine(OPTIONS) Log::Report::Dispatcher::Try->stackTraceLine(OPTIONS) See "Logging" in Log::Report::Dispatcher $obj->translate(HASH-of-OPTIONS, REASON, MESSAGE) See "Logging" in Log::Report::Dispatcher Status $obj->failed Returns true if the block was left with an fatal message. $obj->showStatus If this object is kept in $@, and someone uses this as string, we want to show the fatal error message. The message is not very informative for the good cause: we do not want people to simply print the $@, but wish for a re-cast of the message using reportAll() or reportFatal(). $obj->success Returns true if the block exited normally. $obj->wasFatal(OPTIONS) Returns the Log::Report::Exception which caused the "try" block to die, otherwise an empty LIST (undef). -Option--Default class undef class => CLASS|REGEX Only return the exception if it was fatal, and in the same time in the specified CLASS (as string) or matches the REGEX. See Log::Report::Message::inClass() OVERLOADING
overload: boolean Returns true if the previous try block did produce a terminal error. This "try" object is assigned to $@, and the usual perl syntax is "if($@) {...error-handler...}". overload: stringify When $@ is used the traditional way, it is checked to have a string content. In this case, stringify into the fatal error or nothing. SEE ALSO
This module is part of Log-Report distribution version 0.94, built on August 23, 2011. Website: http://perl.overmeer.net/log-report/ LICENSE
Copyrights 2007-2011 by Mark Overmeer. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2011-08-23 Log::Report::Dispatcher::Try(3pm)
All times are GMT -4. The time now is 01:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy