Hi My first contribution to the list!
Probably the simplest way to do this is (once you have apache2 installed and working) to create a script that looks a bit like this: !#/usr/bin/perl use strict; use warnings; sub mylogparser { Your script } mylogparser (); print "Content-type: text/html\n\n"; #VERY IMPORTANT!! print <<WEBPAGE; #Start multiline variable which is just printed as HTML <all of your HTML goes here including reference to CSS etc and use $variables for dynamic content e.g your log data> WEBPAGE #note no semi colon Your script will run on load so if you want to refresh it, maybe use a java script to do that. For pointers consider CGI but this will do what you are after. Use a WYSIWYG editor to make it pretty and keep a copy to reuse :) Hth. On 8 May 2013, at 07:04, Asad <asad.hasan2...@gmail.com> wrote: > Hi All , > > Thanks to you all for the inputs . I have created the following > script : > > use warnings; > use strict; > use File::Slurp qw(read_file); > use constant LIMIT => 3; ## Number of lines wanted > use constant UPPERLIMIT => 9; > > open (OUTFILE, '>','d:\perl\OUTPUT.TXT'); > > #my $file = $ARGV[0]; > > my $filename = 'LOGFILE'; > > open(FH, '<', $filename) or die $!; > > my @lines = read_file($filename); > > for ( 0 .. $#lines ) { > if ( $lines[$_] =~ m{\b(VERIFICATION_FAILED)\b}i ) { > print "$_\n"; > print $lines[$_]; > print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ + UPPERLIMIT > ], $/; > } > elsif ($lines[$_] =~ m{\bfatal\b}i) > { > print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ + UPPERLIMIT > ], $/; > } > elsif ($lines[$_] =~ m{\b'Exception Severity: 1'\b}) > { > print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ + UPPERLIMIT > ], $/; > } > elsif ($lines[$_] =~ m{\bstop\b}i) > { > print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ + UPPERLIMIT > ], $/; > } > elsif ($lines[$_] =~ m{\bfail\b}i) > { > print OUTFILE join " " => '*', @lines[ $_ - LIMIT .. $_ + UPPERLIMIT > ], $/; > } > else > { > print " No Errors found \n"; > } > > Please review if the above code seems ok . > > Also want to know how to get this to UI(html page) interface for example a > html page which has a browse button to select the log file and it displays > the output parsing through the logic any module which this does or what you > suggest. > > Any pointers for UI interface or any book I can refer would be helpful. > > > Thanks, > > > > On Sat, Apr 13, 2013 at 9:20 PM, Asad <asad.hasan2...@gmail.com> wrote: >> Hi All , >> >> Greetings ! >> >> I have completed O'Reily first book Learning Perl . Started writing >> small perl programs . However I basically do log file analysis , hence was >> thinking is there any perl code around in any of the book or if anyone >> already developed for the following requirement : >> >> Nowadays I manually read the log files to read the errors which are either >> fatal or warning or ignorable . The purpose is I want to develop a web page >> as in I upload this log file and it searches for those keywords (fatal or >> warning or ignorable) and if found those keywords display the 10line before >> it and after it . >> >> Please share your thoughts. Unable to start . >> >> Thanks, >> -- >> Asad Hasan >> +91 9945666911 > > > > -- > Asad Hasan > +91 9945666911