Hi , Here is my code which i wrote to get Comma seperated output.
#!/usr/bin/perl print "Hello, World...\n"; 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 $Time_Stamp ; my $User_Name; my $Success; my $Failure; my $ErrorCode; my $ErrorMsg; while(my $line = <$log>) { $n++; $line =~ tr/\r\n//d; if ($line =~ /^(.*)INFO:.*recvd AA_BIN_MSG_GET_WLT/) { $Time_Stamp = $1; while ( $line = <$log> ) { if ($line =~ /recvd AA_BIN_MSG_VER_CHG$/) { while ( $line = <$log>) { if ($line =~ /Cert.*UserID=(\d+)/) { $User_Name = $1 ? $1 : "NULL" ; } } while ( $line = <$log> ) { if ($line =~ /ArcotID Auth SUCCESS/) { $Success = "Success"; } } while ( $line = <$log> ) { if ($line =~ /Auth fail due to signature verificat +ion/) { $Failure = "Failure"; } } while ( $line = <$log> ) { if ($line =~ /Authentication mechanism returned \[ +(\d+)\]/) { $ErrorCode = $1; } } while ( $line = <$log>) { if ($line =~ /(Auth fail due to signature verifica +tion.)/) { $ErrorMsg = $1 ? $1 : "Null"; } } }print "$Time_Stamp , $User_Name , $Success , $Failure , $ +ErrorCode , $ErrorMsg \n"; next; } } }
I am getting all the values in the variables but the final outcome prints it only once not for all and the formating suggestions in my code is also needed. Kindly sugegst me something according to my code. The snippet of the logfile is like this.
Native Server: recvd AA_BIN_MSG_GET_WLT Fri May 29 18:31:53.467 2009 Morocco Standard Time INFO: pid 3216 t +id 2672: 17: 132357: ArAuthFrameworkImpl::doAuth::11:132357:: Authent +ication mechanism returned [1] for AuthIdentity [;ARCARD] Fri May 29 18:31:53.467 2009 Morocco Standard Time INFO: pid 3216 t +id 2672: 170: 132357: Handle_NSPAdvice:: Handling NSPAdvice for mecha +nism [4] Fri May 29 18:31:53.467 2009 Morocco Standard Time INFO: pid 3216 t +id 2672: 17: 132357: ArAuthFrameworkImpl::doPostAuth::11:132357:: Aut +hentication mechanism returned [1] for AuthIdentity [01302904] Fri May 29 18:31:53.482 2009 Morocco Standard Time INFO: pid 3216 t +id 2672: 60: 132357: Sending Continue with challenge Fri May 29 18:31:53.482 2009 Morocco Standard Time INFO: pid 3216 t +id 2672: 61: 132357: Packet being sent Fri May 29 18:31:53.482 2009 Morocco Standard Time INFO: pid 3216 t +id 2672: 60: 0: Packet Sent (MsgType:110, Size: 1564 Bytes). Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 60: 0: Packet Received (MsgType:109, Size: 1463 Bytes). Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 60: 0: Locale Name[en], Locale ID[1] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 0: 132358: Message: ArAuthBinaryAuthRequestMgr::setSecurityI +nfo: security_info_offset [0] is invalid. Assuming security info not +available. Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 17: 132358: Using session identifier [11:132358] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 17: 132358: ArAuthFrameworkImpl::doPreAuth::11:132358:: Auth +entication mechanism returned [0] for AuthIdentity [] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: Arcot Native Server: recvd AA_BIN_MSG_VER_CHG Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: Cert Subject String....:[CN=01302904;O=MLS; Use +rID=0123456; CardName=ARCARD] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: Cert issuer............:[] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: Cert serial String.....:[e93b] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: ArcotId Certificate received with signature hav +e ArcotExtension. Cert issuer=CN= Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: ArcotID Auth SUCCESS (serial Number [e93b]) For Fail the line is -- Auth fail due to signature verification.Serial Number [11872] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: Session tracker Id associated with verify signe +d challenge[11:132351] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 17: 132358: ArAuthFrameworkImpl::doAuth::11:132351:: Authent +ication mechanism returned [0] for AuthIdentity [] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: Handle_NSPAdvice:: Handling NSPAdvice for mecha +nism [4] Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: Handle_NSPAdvice::NSP Action :[NSP_RESET] Fri May 29 18:31:53.514 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 170: 132358: NSP Update Query is based on Serial Number Fri May 29 18:31:53.514 2009 Morocco Standard Time INFO: pid 3216 t +id 2888: 17: 132358: ArAuthFrameworkImpl::doPostAuth::11:132351:: Aut +hentication mechanism returned [0] for AuthIdentity [01302904]
Thanks NT

In reply to Comma seperated output by namishtiwari

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.