Sponsored Content
Top Forums Shell Programming and Scripting Help to create a script to parse log files Post 302443879 by pravin27 on Tuesday 10th of August 2010 10:14:15 AM
Old 08-10-2010
Hi Try this,

parser.pl
Code:
#!/usr/bin/perl

$filename=shift;
$sum_type=shift;
chomp($sum_type,$filename);

open(FH,"<","$filename") || die "cannot open file \n";

while (<FH>) {
chomp;
if (/\s$sum_type\sSUMMARY\s\[(\w+)\.\w+\]\s(\w+)\scnt\/(\d+)\s/) {
#print $_,"\n";
print "$sum_type SUMMARY $1 $2 $3 \n";
}
}
close(FH);

Code:
perl parser.pl logfilename summary_type


Last edited by pravin27; 08-10-2010 at 11:26 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell scripts that parse log files

hi all ,i would like a shell script that parses log files and checks the contents for any anonalities,please help,thanks (4 Replies)
Discussion started by: trueman82
4 Replies

2. 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

3. Homework & Coursework Questions

shell script that can create, monitor the log files and report the issues for matching pattern

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write an automated shell program(s) that can create, monitor the log files and report the issues for matching... (0 Replies)
Discussion started by: itian2010
0 Replies

4. Shell Programming and Scripting

Need a Script - Parse the log backup

Hello all, I need a script to parse the backup logs. I am newbie to scripting, please help. (7 Replies)
Discussion started by: sandeep007
7 Replies

5. UNIX for Dummies Questions & Answers

How can i parse my Unix log files??

Hello, i would like to parse Unix log files and i would like to use a Unix syslog analyzer. I'm going to use Eucalyptus and i would like to parse its log files. Is there any open source/free syslog parser?? Thanks, in advance! (2 Replies)
Discussion started by: g_p
2 Replies

6. Shell Programming and Scripting

awk script to parse results from TWO files

I am trying to parse two files and get data that does not match in one of the columns ( column 3 in my case ) Data for two files are as follows A.txt ===== abc 10 5 0 1 16 xyz 16 1 1 0 18 efg 30 8 0 2 40 ijk 22 2 0 1 25 B.txt ===== abc... (6 Replies)
Discussion started by: roger67
6 Replies

7. Shell Programming and Scripting

Parse Log & Create Flow Diagram - Ideas/Tools

Hi, I would like to develop a script which parses the log file and generates a flow diagram ( graphical display ). We have an application, for understanding the sequence of functions call made, we have an debug line at "ENTRY/EXIT" of function. I have a small log parsing script which grep the... (2 Replies)
Discussion started by: ennstate
2 Replies

8. Shell Programming and Scripting

Perl script to parse all files in the folder

Hello Smart People! I have a perl script that will import xml data into an access db. I would like to modify it so it will automatcially parse through all xml files in the folder. I swa a post but couldnt get it working. her is what my scrip looks like, i only list the top if you need more... (3 Replies)
Discussion started by: cowboymaverick
3 Replies

9. Shell Programming and Scripting

awk Parse And Create Multiple Files Based on Field Value

Hello: I am working parsing a large input file which will be broken down into multiples based on the second field in the file, in this case: STORE. The idea is to create each file with the corresponding store number, for example: Report_$STORENUM_$DATETIMESTAMP , and obtaining the... (7 Replies)
Discussion started by: ec012
7 Replies

10. Shell Programming and Scripting

Parse log files

Hi all, We are having a sample log like .... test.log:2015.03.17 06:16:24 >> ABC.generateMethod() MethodAException while processing Request! DataForm: Header --- dtd: template.dtd, titleName: berger, requestId: 1503170032131, documentName: invoice123, hostName: acme.net, userName: userABC... (10 Replies)
Discussion started by: tandrei
10 Replies
SGML::Parser::OpenSP::Tools(3pm)			User Contributed Perl Documentation			  SGML::Parser::OpenSP::Tools(3pm)

NAME
SGML::Parser::OpenSP::Tools - Tools to process OpenSP output DESCRIPTION
Routines to post-process OpenSP event data. UTILITY FUNCTIONS
specified_attribute($attribute) specified_attribute returns a true value if the attribute is of type "cdata" or "tokenized" and has its "Defaulted" property set to "specified". For example sub start_element { my $self = shift; my $elem = shift; my @spec = grep specified_attribute($_), values %{$elem->{Attributes}}; # @spec contains all explicitly specified attributes } defaulted_attribute($attribute) defaulted_attribute returns a true value if the attribute is of type "cdata" or "tokenized" and has its "Defaulted" property set to something but "specified". For all attributes, the following always holds true, !defined(attribute_value($_)) or defaulted_attribute($_) or specified_attribute($_) since only defaulted and specified attributes can have a value. value_attribute($attribute) Returns true if the value can have a value, i.e., it is either specified or defaulted. attribute_value($attribute) attribute_value returns a textual representation of the value of an attribute as reported to a "start_element" handler or "undef" if no value is available. split_message($message, $filename, $open_ent, $error_num, $open_elem) split_message splits an OpenSP error message into its components, the error or warning message, an optional auxiliary message that provides additional information about the error, like the first occurence of an ID in case of duplicate IDs in a document, each accompanied by line and column numbers relevant to the message, and depending on the parser configuration the open entities for the message, the error number of the message and a list of the current open elements. It returns a hash reference like # this is always present primary_message => { Number => 141, # only if $p->show_error_numbers(1) Module => 554521624, # only if $p->show_error_numbers(1) ColumnNumber => 9, LineNumber => 12, Severity => 'E', Text => 'ID "a" already defined' }, # only some messages have an aux_message aux_message => { ColumnNumber => 9, LineNumber => 11, Text => 'ID "a" first defined here' }, # iff $p->show_open_elements(1) and there are open elements open_elements => 'html body[1] (p[1])', # iff $p->show_open_entities(1) and there are open entities # other than the document, but the document will be reported # if the error is in some other entity open_entities => [ { ColumnNumber => 55, FileName => 'example.xhtml', EntityName => 'html', LineNumber => 2 }, ... ], This would typically be used like sub error { my $self = shift; my $erro = shift; my $mess = $erro->{Message}; # parser is the SGML::Parser::OpenSP # object stored in the handler object my $loca = $self->{parser}->get_location; my $name = $loca->{FileName}; my $splt = split_message($mess, $name, $self->{parser}->show_open_entities, $self->{parser}->show_error_numbers, $self->{parser}->show_open_elements); # ... } A more convenient way to access this function is provided by the "SGML::Parser::OpenSP" module which you can use like sub error { my $self = shift; my $erro = shift; my $mess = $self->{parser}->split_message($erro); # relevant data is now $mess and $erro->{Severity} # of which the latter provides more detailed information # than $mess->{primary_message}->{Severity}, see the # SGML::Parser::OpenSP documentation for details } split_pi($data) split_pi splits the data of a processing instructions at the first white space character into two components where white space character is defined in the $WHITESPACE package variable, qr/[x20x09x0dx0a]/ by default. It returns "undef" if there is no data to split. sub pi { my $self = shift; my $proc = shift; my ($target, $data) = split_pi($proc->{Data}); # ... } AUTHOR
/ COPYRIGHT / LICENSE Copyright (c) 2006-2008 Bjoern Hoehrmann <bjoern@hoehrmann.de>. This module is licensed under the same terms as Perl itself. perl v5.14.2 2008-06-29 SGML::Parser::OpenSP::Tools(3pm)
All times are GMT -4. The time now is 05:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy