The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl Error with ftptail script Cooki3s! UNIX for Dummies Questions & Answers 2 05-04-2009 11:46 AM
SolarisCron job perl script execution error sonu2die4 Shell Programming and Scripting 4 02-06-2009 05:22 PM
Perl script error pietie Shell Programming and Scripting 4 10-15-2008 09:05 AM
Perl Script Error with find command MKNENI Shell Programming and Scripting 4 03-26-2008 12:02 PM
String replace perl script error MobileUser Shell Programming and Scripting 6 05-04-2006 09:18 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-12-2009
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
error in output of perl script

Hi,

This is my piece of code.
Code:
my $logFile = $ARGV[0]; 
die "usage: $0 <logFile>" unless $logFile; 
die "Logfile $logFile doesn't exist" unless -f "$logFile"; 
open(my $log, "<", $logFile) or die "Can't open $logFile for reading."; 
print "Processing file $logFile...\n"; 
#my $authenticates = {}; 
my $n = 0;
my $ArcotIDError_Count = 0;
my $QnAError_Count = 0;
my $UPError_Count = 0;
my $OTPError_Count = 0;
my $errorCode;
while(my $line = <$log>) { 
   	$n++; 
    $line =~ tr/\r\n//d; 
	if($line =~ /Handling NSPAdvice for mechanism \[4\]/) {
		while ( $line = <$log> ) {
			if ($line =~ /Authentication mechanism returned \[(\d+)\]/) {
				my $errorCode = $1;
				print "$errorCode\n";
				if ($errorCode != 0 && $errorCode != 1) {
                  $ArcotIDError_Count++;
				}
			}
			next;
		}
	}	
	}
	print "Total Number Of ArcotID Authentication ErrorCode returned is $ArcotIDError_Count\n";
The output for this comes as 354 but the actual output is 142. I am not finding any problem in the code and logic also seems to me ok.
Can anyone suggest me if any problem is there.
One more thing i like to know is that--
I can add OR condition in this statement
Code:
if($line =~ /Handling NSPAdvice for mechanism \[4\]/)
as
if($line =~ /Handling NSPAdvice for mechanism \[4\]/ || /Handling NSPAdvice for mechanism \[3\]/)
any other better way to do it here.

Thanks
NT
  #2 (permalink)  
Old 06-15-2009
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Please advise me for the likely reasons, is there any problem in the code.

Thanks
NT
  #3 (permalink)  
Old 06-15-2009
ejdv ejdv is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 46
Hi NT,

Don't know if I personally can be of any help, but I if you supply the contents of the $logFile, perhaps this will be useful for the persons trying to help.

You can also try to use the debugger (#!/bin/perl -w -d) to see where the code does something different than expected.

And do you expect 354 as output but you get 142, or do you get 142 where you expect 354 ?

E.J.
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0