perl help for comma seperated output


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl help for comma seperated output
# 1  
perl help for comma seperated output

Hi,

how can i make a comma seperated output summary.
i attached the sample log file.

I have to capture these data in the log file.

Arcotid
Time Stamp, Username, Success, Failure, Error Code, Error Message

In the log snippet the userID can be found in-

Code

Arcot Native Server: recvd AA_BIN_MSG_VER_CHG
Cert Subject String....:[CN=01095848;O=MLS; UserID=012345; CardName=ARCARD]

Success and failure are like this-
Code

ArcotID Auth SUCCESS (serial Number [e93b])
Auth fail due to signature verification.Serial Number [11872](This is error message also)
Code


error code is -
Authentication mechanism returned [3], here 3 is error code and for success error code is always 0.

Formatting and printing in csv format is the part i am unaware,so i require your help in this.I need to do this for all authentication methods so if i get help in one i will be able to do it for rest.

Thanks
NT

Last edited by namishtiwari; 06-15-2009 at 07:58 AM..
# 2  
Use the perl string functions to parse the elements to log, then just use a print statement to add the rest.

print OUT $id . "," . $ele1 . "," . $ele2 . "," . $ele3

The work is in the parsing, the output is just tedious...
# 3  
namishtiwari,

please show us what you have tried so far.
# 4  
Quote:
Originally Posted by KevinADC
namishtiwari,

please show us what you have tried so far.
Code:
#!/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 verification/) {
						$Failure = "Failure";
					}
				}
				while ( $line = <$log> ) {
					if ($line =~ /Authentication mechanism returned \[(\d+)\]/) {
						$ErrorCode = $1;
					}
				}
				while ( $line = <$log>) {
					if ($line =~ /(Auth fail due to signature verification.)/) {
						$ErrorMsg = $1 ? $1 : "Null";
					}
				}
			}print "$Time_Stamp , $User_Name , $Success , $Failure , $ErrorCode , $ErrorMsg \n";
		}
	}

				
}

The Log File snippet is like this--
Code:
Native Server: recvd AA_BIN_MSG_GET_WLT
Fri May 29 18:31:53.467 2009 Morocco Standard Time INFO:    pid 3216 tid 2672: 17: 132357: ArAuthFrameworkImpl::doAuth::11:132357:: Authentication mechanism returned [1] for AuthIdentity [;ARCARD]
Fri May 29 18:31:53.467 2009 Morocco Standard Time INFO:    pid 3216 tid 2672: 170: 132357: Handle_NSPAdvice:: Handling NSPAdvice for mechanism [4]
Fri May 29 18:31:53.467 2009 Morocco Standard Time INFO:    pid 3216 tid 2672: 17: 132357: ArAuthFrameworkImpl::doPostAuth::11:132357:: Authentication mechanism returned [1] for AuthIdentity [01302904]
Fri May 29 18:31:53.482 2009 Morocco Standard Time INFO:    pid 3216 tid 2672: 60: 132357: Sending Continue with challenge
Fri May 29 18:31:53.482 2009 Morocco Standard Time INFO:    pid 3216 tid 2672: 61: 132357: Packet being sent
Fri May 29 18:31:53.482 2009 Morocco Standard Time INFO:    pid 3216 tid 2672: 60: 0: Packet Sent     (MsgType:110, Size: 1564 Bytes).
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 60: 0: Packet Received (MsgType:109, Size: 1463 Bytes).
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 60: 0: Locale Name[en], Locale ID[1]
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 0: 132358: Message: ArAuthBinaryAuthRequestMgr::setSecurityInfo: 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 tid 2888: 17: 132358: Using session identifier [11:132358]
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 17: 132358: ArAuthFrameworkImpl::doPreAuth::11:132358:: Authentication mechanism returned [0] for AuthIdentity []
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 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 tid 2888: 170: 132358: Cert Subject String....:[CN=01302904;O=MLS; UserID=0123456; CardName=ARCARD]
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 170: 132358: Cert issuer............:[]
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 170: 132358: Cert serial String.....:[e93b]
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 170: 132358: ArcotId Certificate received with signature have ArcotExtension. Cert issuer=CN=
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 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 tid 2888: 170: 132358: Session tracker Id associated with verify signed challenge[11:132351]
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 17: 132358: ArAuthFrameworkImpl::doAuth::11:132351:: Authentication mechanism returned [0] for AuthIdentity []
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 170: 132358: Handle_NSPAdvice:: Handling NSPAdvice for mechanism [4]
Fri May 29 18:31:53.498 2009 Morocco Standard Time INFO:    pid 3216 tid 2888: 170: 132358: Handle_NSPAdvice::NSP Action :[NSP_RESET]
Fri May 29 18:31:53.514 2009 Morocco Standard Time INFO:    pid 3216 tid 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 tid 2888: 17: 132358: ArAuthFrameworkImpl::doPostAuth::11:132351:: Authentication mechanism returned [0] for AuthIdentity [01302904]

The formating is issue for me. Please give your suggestions in this.

Last edited by namishtiwari; 06-15-2009 at 07:33 AM..
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #167
Difficulty: Easy
The Transmission Control Protocol (TCP) is one of the least used protocols of the Internet protocol suite.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk comma seperated value within double quote

Hi, I have a data file separated by comma, data enclosed by "" head file.txt "HD","Sep 13 2016 1:05AM","0001" "DT","273093045","192534" "DT","273097637","192534" .. I want to get the 3rd column value (0001) to be assigned to my variable I tried FILE_VER=`cat file.txt | awk... (2 Replies)
Discussion started by: Prasannag87
2 Replies

2. Shell Programming and Scripting

Need Help in rearranging the content of a file comma seperated

I have a file with the below content a = test1 b = test2 a = test3 b= test4 c = test6 b = test5 d = test7 d = test9 Need the output to be as follows a = test1,test3 b = test2, test5 c = test6 d = test7, test9 (4 Replies)
Discussion started by: iron_michael86
4 Replies

3. Shell Programming and Scripting

Convert comma seperated file to line seperated.

Hi, I have data like this. 1,2,3,4 Output required: 1 2 3 4 I am trying to use tr function but getting error. Help is appreciated. (6 Replies)
Discussion started by: pinnacle
6 Replies

4. Shell Programming and Scripting

Passing Comma seperated arguments

Hi How to takes coma seperated arguments and and parsing each argument to varaiable that has used further in the script. (1 Reply)
Discussion started by: Reddy482
1 Replies

5. Shell Programming and Scripting

Script to append a value seperated by comma

I have a file like below. How can I add a new value after moss separated by a comma. This adding script should work in such a way that each time i pass a value it should be added one after the other separated by commas. hru:122: hello:123:john,philip,mary,kp,moss hi:124: bye:125: Can... (7 Replies)
Discussion started by: Tuxidow
7 Replies

6. Shell Programming and Scripting

Removing blank lines from comma seperated and space seperated file.

Hi, I want to remove empty/blank lines from comma seperated and space seperated files Thanks all for help (11 Replies)
Discussion started by: pinnacle
11 Replies

7. UNIX for Dummies Questions & Answers

Search and then concat 4m other file (comma seperated)

My query is now a bit simplified. file1.txt names; ID; value1 ; values N; ABC; 1 ; a18 ; CDF; 2 ; b16 ; .. ABC; 1 ; c13 ; EFG; 3 ;d12 ; ... file2.txt ID(Unique);smVals; smVal1; smVal N; 1; ; ; ; 2; ..; ..; ..; 3; ..; ..; ..; 4; ..; ..; ..; ... (1 Reply)
Discussion started by: szchmaltz
1 Replies

8. Shell Programming and Scripting

change list to comma seperated items

I have a list of servers in a file called serverlist like this server1 server2 server3 i need to have them (with no trailing comma, the program does not like that) server1,server2,server3 so far i have been using HOSTS=/tmp/serverlist HOSTS=${HOSTS:-$(grep -Ev "^#|^$"... (2 Replies)
Discussion started by: insania
2 Replies

9. Shell Programming and Scripting

Comma Seperated List of Values

Hi, I have a comma seperated list of values: export list="red,blue,white,yellow" Given a value in a variable "look", i want to check whether the value is available in the above list. But the result should be based on exact string match and not part of the string. I am using following... (9 Replies)
Discussion started by: brap45
9 Replies

10. Shell Programming and Scripting

Handling .CSV( Comma seperated value) in awk

Hi Guys, I am trying to reading in comma seperated values in awk. I can set the delimiter to be a comma, but the tricky part is that commas that appear within quotes are not to be considered as delimiters. Could someone please help. Regards, Laud (1 Reply)
Discussion started by: Laud12345
1 Replies

Featured Tech Videos