namishtiwari has asked for the wisdom of the Perl Monks concerning the following question:
when i ran the program like this--#!/usr/bin/perl use strict; use warnings; my $Time_Stamp ; my $User_Name; my $Success; my $Failure; my $ErrorCode; my $ErrorMsg; my $logDir = $ARGV[0]; my $logPrefix = $ARGV[1]; my $log; my $line; die "usage: $0 <logDir> <logPrefix>" unless $logDir and $logPrefix; die "Log dir $logDir doesn't exist" unless -d "$logDir"; for my $logFile ( glob("$logDir/${logPrefix}*") ) { open($log, "<", $logFile) or die "Can't open $logFile for reading. +"; open(FP_OUT,">temp12") or die "cannot create file temp1 for writin +g"; print "Processing file $logFile...\n"; OUTER: while( $line = <$log> ) { chomp($line); if ($line =~ /^(.*)INFO:.*QNA Step - AUTH IN PROGRESS/) { $Time_Stamp = $1; printf FP_OUT "$Time_Stamp,"; QnA_search_for_sucess_or_failure() ; #QnA_search_for_userID() ; next OUTER; } } } sub QnA_search_for_sucess_or_failure { OUTER1: while ( $line = <$log> ) { if ($line =~ /QNA Auth.*Success\s*and\s*Complete/) { printf FP_OUT "Success,"; print STDOUT "In Success,\n"; $ErrorMsg="null"; while ( $line = <$log> ) { if ($line =~ /ArAuthFrameworkImpl::doPostAuth.*Au +thentication\s*mechanism\s*returned\s*\[(..*)\]\s*for\s*AuthIdentity\ +s*\[(..*)\]/) { print "$2\n"; printf FP_OUT "$2, ${1}, $ErrorMsg\n"; last OUTER1; } } } if($line =~ /Message.*QNA\s*Auth\s*Failed\((..*)\).*/) { $ErrorMsg=$1; printf FP_OUT "Failure,"; print STDOUT "In Failure,\n"; while ( $line = <$log> ) { if ($line =~ /ArAuthFrameworkImpl::doPostAuth +.*Authentication\s*mechanism\s*returned\s*\[(..*)\]\s*for\s*AuthIdent +ity\s*\[(..*)\]/) { print "$2\n"; printf FP_OUT "$2, ${1}, $ErrorMsg\n"; last OUTER1; } } } } } The below snippet is taken from the logfile.I am using while loops bec +ause there are many lines above and inbetween this snippet. <CODE> Tue May 19 22:55:13.649 2009 Morocco Standard Time INFO: pid 2172 t +id 3412: 160: 10083504: QNA Step - AUTH IN PROGRESS Tue May 19 22:55:13.649 2009 Morocco Standard Time INFO: pid 2172 t +id 3412: 160: 10083504: QNA Auth - Success and Complete, Returning SU +CCESS Tue May 19 22:55:13.665 2009 Morocco Standard Time INFO: pid 2172 t +id 3412: 17: 10083504: ArAuthFrameworkImpl::doPostAuth::1:10083487:: +Authentication mechanism returned [0] for AuthIdentity [12345] and for QnA failure the line comes like this in place of success line- +- Tue May 19 22:56:21.962 2009 Morocco Standard Time INFO: pid 2172 t +id 688: 160: 10083554: Err[115261735], Message: QNA Auth Failed(Inval +id Credentials), Repeating the challenge and Returning FAILED
but in output file that is temp12, it is not printing anything. Kindly suggest wha is wrong here.C:\Perl Script>perl QnA_Authentication.pl . logfile.txt Processing file ./logfile.txt... In Success, 01503164 In Success, 01822755 In Failure, 01401058 Processing file ./logfile.txt.bak...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: wrong output
by GrandFather (Saint) on Jul 02, 2009 at 08:28 UTC | |
by apl (Monsignor) on Jul 02, 2009 at 14:04 UTC | |
by namishtiwari (Acolyte) on Jul 02, 2009 at 09:11 UTC | |
|
Re: wrong output
by jethro (Monsignor) on Jul 02, 2009 at 08:37 UTC | |
by namishtiwari (Acolyte) on Jul 02, 2009 at 08:47 UTC | |
by namishtiwari (Acolyte) on Jul 02, 2009 at 11:03 UTC | |
by jethro (Monsignor) on Jul 02, 2009 at 11:38 UTC | |
by ww (Archbishop) on Jul 02, 2009 at 11:26 UTC |