The UNIX and Linux Forums  


Go Back   De Unix-en Linux Forum > Top Forums > Programmeren en Shell Scripting
.
google unix.com



Programmeren en Shell Scripting Post vragen over KSH, CSH, SH, Bash, Perl, PHP, sed, awk en andere shell scripts en shell scripting talen hier.

Meer UNIX en Linux Forum Onderwerpen Misschien vindt u Helpful
Draad Thread Starter Forum Antwoorden Last Post
fout in de productie van perl script namishtiwari Programmeren en Shell Scripting 2 06-15-2009 06:02
tr commando geven verkeerde uitgang Usha rao Programmeren en Shell Scripting 8 05-08-2009 08:13
Sorteren commando geven verkeerde uitgang Usha rao Programmeren en Shell Scripting 8 04-07-2009 09:54
Perl script probleem. Wat doe ik verkeerd? SkySmart Programmeren en Shell Scripting 14 03-19-2009 05:22 PM
Afdrukken naar een Savin - Grootte van de output verkeerde h1timmboy AIX 2 02-28-2006 09:19

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Zoeken in deze Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2009
namishtiwari namishtiwari is offline Forum Advisor  
Geregistreerde gebruiker
  
 

Join Date: Aug 2007
Locatie: Bangalore
Posts: 377
verkeerde uitgang in perl script

Hoi,

Hier is mijn stukje code --


Code:
#!/usr/bin/perl

my $Time_Stamp ;
my $User_Name;
my $Success;
my $Failure;
my $ErrorCode;
my $ErrorMsg;
my $logDir = $ARGV[0]; 
my $logPrefix = $ARGV[1]; 

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 writing";
	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.*Authentication\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*AuthIdentity\s*\[(..*)\]/)

						  {
							  
							  print "$2\n";
							  printf FP_OUT "$2, ${1}, $ErrorMsg\n";
							  last OUTER1;
						  }

					  }

				 
	   }
	  }
	  
}

Het onderstaande fragment is afkomstig uit de logfile.I ben using terwijl lussen, omdat er veel lijnen boven en tussenmaat dit fragment.

Code:
Tue May 19 22:55:13.649 2009 Morocco Standard Time INFO:    pid 2172 tid 3412: 160: 10083504: QNA Step - AUTH IN PROGRESS
Tue May 19 22:55:13.649 2009 Morocco Standard Time INFO:    pid 2172 tid 3412: 160: 10083504: QNA Auth - Success and Complete, Returning SUCCESS
Tue May 19 22:55:13.665 2009 Morocco Standard Time INFO:    pid 2172 tid 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 tid 688: 160: 10083554: Err[115261735], Message: QNA Auth Failed(Invalid Credentials), Repeating the challenge and Returning FAILED

toen ik liep het programma zoals dit --

Code:
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...

maar in de output bestand dat wordt temp12, is het niet afdrukken niets.
Kindly suggereren WHA is verkeerd hier.
  #2 (permalink)  
Old 07-03-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Locatie: Innsbruck, Oostenrijk
Berichten: 1891
Je moet het spoelen van de productie zo nu en dan.

selecteer FP_OUT; $ | \u003d 1; selecteer stdout;
  #3 (permalink)  
Old 07-03-2009
prasperl prasperl is offline
Geregistreerde gebruiker
  
 

Join Date: juni 2009
Posts: 22
Lijkt te werken boete

Ik gebruikte de log-informatie als u had gegeven hierboven.


De o / p

Verwerking bestand xxxxxxxxxxxxxxxxxxxxxxxxxx / bestand.txt ...

In Succes,
12345


In temp12,
Dinsdag 19 mei 22:55:13.649 2009 Marokko Standard Time, Succes, 12345, 0, null


is dit wat je verwachtte?
Reply

Bladwijzers

Thread Tools Zoeken in deze Thread
Zoeken in deze Thread:

Uitgebreid zoeken
Display Modes Beoordeel deze draad
Beoordeel deze draad:

Posting Regels
Jij mag niet Post Nieuwe threads
Jij mag niet na antwoorden
Jij mag niet post attachments
Jij mag niet bewerk uw berichten

BB code is Aan
Smilies zijn Aan
[IMG] code Aan
HTML-code is Uit
Trackbacks zijn Aan
Pingbacks zijn Aan
Refbacks zijn Aan




Alle tijden zijn GMT -4. Het is nu 05:35.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Vertalingen Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
De Unix-en Linux Forums Copyright © 1993-2009. Alle rechten Reserved.Ad Beheer door RedTyger

Content Relevante URL's door vBSEO 3.2.0