Perl Script Help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl Script Help
# 1  
Old 02-24-2009
Perl Script Help

Hi Experts,

I need help in writing a perl script which can help me in doing the following....

1. Read the user name and session id from the sample log file provided.
2. Print the header as risk_assesment for userid(value).
2. Print the line containing End-to-end time in miliseconds.
3. There are thoudands of user and i have to calculate the time taken for all the users. The entry for the user name starts at the point where these lines are
[CODE]
Next State: risk_assessment
2009-02-18 00:00:11,687 [TP-Processor11] DEBUG BaseController,(TP-Processor11:301) - Next state: assessrisk.htm
Session id can be found in there.


The portion of the log file for the one user id and session id is below---
Code:
2009-02-18 00:00:11,687 [TP-Processor11] INFO  FlowController,(TP-Processor11:121) - Next State: risk_assessment
2009-02-18 00:00:11,687 [TP-Processor11] DEBUG BaseController,(TP-Processor11:301) - Next state: assessrisk.htm
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - Entered callRF
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - Found DID cookie for RF.
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - Returning DID: FXIbNjt4llWFmvPKHSGZoMvZ60WQTd5vFZ3Em+J2jbkZfMHoJxI0XAcDcZfy5G6F
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - Username: 01376128
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - Groupname: MLS
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - Device Signature: 
 {"DEVICESIG":{"VERSION":"1.5","OS_BROWSER":{"browser_ver":"3.0.6","os":"PPC Mac OS X 10.4","browser":"Netscape"},"SCREEN":
 {"colorDepth":"24","availWidth":"1680","width":"1680","height":"1050","availHeight":"1024"},"HTTP_HEADER":
 {"user-agent":"Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6"},"OPTIONAL":
 {"SOFTWARE":[]},"USER_PREF":{"sys_lang":"en-us","timezone":"480","user_lang":"en-us"}}}
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - DID retrieved from client system: 
 FXIbNjt4llWFmvPKHSGZoMvZ60WQTd5vFZ3Em+J2jbkZfMHoJxI0XAcDcZfy5G6F
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - IP Address: 216.75.232.70
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RFRiskAssessmentController,(TP-Processor11:122) - INetAddress received: /216.75.232.70
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RiskFactory,(TP-Processor11:140) - The object is already created
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG RiskXActionAPI,(TP-Processor11:120) - evaluateRiskAfterLogin: XML Request 
 [<POLICYREQ><MESSAGEID>0</MESSAGEID><CALLERID>4 - MLS - MLS: com.arcot.aok.web.controllers.rf.RFRiskAssessmentController</CALLERID>
 <AUTHPARAMS><ACTION>LOGIN</ACTION><CREDENTIAL>ARCOTID</CREDENTIAL></AUTHPARAMS><IDENTITY>
 <USERID>01376128</USERID><GROUP>MLS</GROUP><SUBGROUP>SUBGROUP2</SUBGROUP></IDENTITY>
 <LOCATION><IPADDRESS>216.75.232.70</IPADDRESS></LOCATION>
 <DEVICEID type="http">FXIbNjt4llWFmvPKHSGZoMvZ60WQTd5vFZ3Em+J2jbkZfMHoJxI0XAcDcZfy5G6F</DEVICEID>
 <DEVICESIG>{&quot;DEVICESIG&quot;:{&quot;VERSION&quot;:&quot;1.5&quot;,&quot;OS_BROWSER&quot;
 :{&quot;browser_ver&quot;:&quot;3.0.6&quot;,&quot;os&quot;:&quot;
 PPC Mac OS X 10.4&quot;,&quot;browser&quot;:&quot;Netscape&quot;},&quot;SCREEN&quot;:
 {&quot;colorDepth&quot;:&quot;24&quot;,&quot;availWidth&quot;:&quot;1680&quot;,&quot;width&quot;:&quot;1680&quot;,&quot;
 height&quot;:&quot;1050&quot;,&quot;availHeight&quot;:&quot;1024&quot;},&quot;HTTP_HEADER&quot;:{&quot;user-agent&quot;:&quot;
 Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6&quot;},&quot;
 OPTIONAL&quot;:{&quot;SOFTWARE&quot;:[]},&quot;USER_PREF&quot;:{&quot;sys_lang&quot;:&quot;en-us&quot;,&quot;
 timezone&quot;:&quot;480&quot;,&quot;user_lang&quot;:&quot;en-us&quot;}}}</DEVICESIG></POLICYREQ>]
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG SocketPool,(TP-Processor11:32) - borrowSocket: Trying to get lock localCallGetConnectionFlag false callGetConnectionFlag true
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG SocketPool,(TP-Processor11:37) - borrowSocket: In if(callGetConnectionFlag)
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG SocketPool,(TP-Processor11:68) - borrowSocket: Calling borrowObject
2009-02-18 00:00:11,734 [TP-Processor11] DEBUG PoolableSocketFactory,(TP-Processor11:195) - activateObject not supported : No action taken on Socket[addr=/172.16.64.30,port=7680,localport=3188]
2009-02-18 00:00:11,749 [TP-Processor11] DEBUG SocketPool,(TP-Processor11:70) - borrowSocket: Out of borrowObject
2009-02-18 00:00:11,749 [TP-Processor11] DEBUG SocketPool,(TP-Processor11:78) - borrowSocket: Calling Notify
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG PoolableSocketFactory,(TP-Processor11:184) - Validating Object:Socket[addr=/172.16.64.30,port=7680,localport=3188]
2009-02-18 00:00:11,765 [TP-Processor11] INFO  PoolableSocketFactory,(TP-Processor11:199) - passivateObject called on Socket[addr=/172.16.64.30,port=7680,localport=3188]
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG PoolableSocketFactory,(TP-Processor11:184) - Validating Object:Socket[addr=/172.16.64.30,port=7680,localport=3188]
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG RiskXActionAPI,(TP-Processor11:127) - evaluateRiskAfterLogin: 
 Response Packet [<POLICYSERVERDOC DATATYPE="XML"><POLICYRES><MESSAGEID>0</MESSAGEID><SESSIONID>1:2857064</SESSIONID>
 <ACTION>ALLOW</ACTION><RESPONSECODE>0</RESPONSECODE><ERRORSTRING></ERRORSTRING>
 <ERRORCODE>0</ERRORCODE><TRANSACTIONID>1:2857064</TRANSACTIONID><RISKSCORE>10</RISKSCORE>
 <DEVICEID>FXIbNjt4llWFmvPKHSGZoMvZ60WQTd5vFZ3Em+J2jbkZfMHoJxI0XAcDcZfy5G6F</DEVICEID>
 <RISKDETAIL></RISKDETAIL></POLICYRES></POLICYSERVERDOC>]
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:214) - Error code:0 ErrorMsg:TRANSACTIONID : 1:2857064
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:214) - Error code:0 ErrorMsg:SESSIONID : 1:2857064
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:259) - ArcotPacket MessageID [1]
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:140) - riskAnalysisBuildResponseFromXML: 
 DeviceID [FXIbNjt4llWFmvPKHSGZoMvZ60WQTd5vFZ3Em+J2jbkZfMHoJxI0XAcDcZfy5G6F]
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:141) - riskAnalysisBuildResponseFromXML:  AggregatorID []
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:142) - riskAnalysisBuildResponseFromXML: RiskScore [10]
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:143) - riskAnalysisBuildResponseFromXML: Action [ALLOW]
2009-02-18 00:00:11,765 [TP-Processor11] DEBUG ResponseMessageParser,(TP-Processor11:144) - riskAnalysisBuildResponseFromXML: SessionId [1:2857064]
2009-02-18 00:00:11,765 [TP-Processor11] INFO  RiskXActionAPI,(TP-Processor11:137) - evaluateRiskAfterLogin: donecom.arcot.riskfortAPI.RiskAssessment@25d8c5
2009-02-18 00:00:11,765 [TP-Processor11] INFO  RiskXActionAPI,(TP-Processor11:59) - evaluateRisk: End-to-end time in millisecond 31

I am in need of some help.
I put the things in red which is required, i think that will help you.

Thanks
NT

Note: I edited the post to move code tags closer to logfile and to break up long lines

Last edited by namishtiwari; 02-26-2009 at 04:04 AM.. Reason: moved code tags, broke up long log lines
# 2  
Old 02-24-2009
What have you tried?
Where are you stuck?

Hellish log file......
# 3  
Old 02-24-2009
wow.
Unless I'm missing something there doesn't seem to be anything to tie any of those lines together. If thats the case, you could create your script's logic to check for multiple variables, but thats looks to be hellish in this case also.

So, if you have access to the code you could create your own "debugging" and make that so it that your debugging have a common value. Maybe you could just use the webserver's logs? Looking for the first and last connection?

Is this app yours? Is it a vendor app? What language/code base is it? Is there a database? If there's a database you could use SQL to track your users.

That log file doesn't look like it's going to help you.

Good luck,

Tom de
# 4  
Old 02-24-2009
Quote:
Originally Posted by Tom de
wow.
Unless I'm missing something there doesn't seem to be anything to tie any of those lines together. If thats the case, you could create your script's logic to check for multiple variables, but thats looks to be hellish in this case also.

So, if you have access to the code you could create your own "debugging" and make that so it that your debugging have a common value. Maybe you could just use the webserver's logs? Looking for the first and last connection?

Is this app yours? Is it a vendor app? What language/code base is it? Is there a database? If there's a database you could use SQL to track your users.

That log file doesn't look like it's going to help you.

Good luck,

Tom de
He did define where a record begins:

Next State: risk_assessment

And this must be the end:

evaluateRisk: End-to-end time in millisecond 31

That would be easy enough to find, but hell if I'm going to try and decipher the rest of the lines in that file. If he can clarify better what records need to pulled from the file and show some effort I am willing to help.
# 5  
Old 02-24-2009
Unfortunatally, like most log files, the user entries will be mixed within each other. So having the first point of the session and last won't help, as the lines in-between probably won't just be one user, but many users.
# 6  
Old 02-25-2009
I am not familiar with Perl much, though i know some shell scripting, i am trying to grep the records,but in perl we dont have that option.If you can help me out with some syntax that will me much appericiable.I need three values user name, session id and the end to end time printed. they are there in the records.

Thanks
NT

Last edited by namishtiwari; 02-25-2009 at 02:49 AM.. Reason: added some explanation
# 7  
Old 02-25-2009
Perl is like grep on steroids. I understand what you are looking for, but I don't think you'll find it in the log/debug output you posted - for the reasons I've posted already.

So, do you have any answers to our posts? What have you tried already ( post code and output plz.).

Tom de

Last edited by Tom de; 02-25-2009 at 02:00 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

Excuting perl script from within a perl script with variables.

Not sure what I am doing wrong here, but I can print the list with no issue. Just a blank screen with the 'do'. #!/usr/bin/perl open FILE, "upslist.txt"; while ($line=<FILE>){ if ($line=~/^(.*?),(.*?)$/){ #print "ups:$1 string:$2\n"; do 'check_snmp_mgeups-0.1.pl -H $1 -C $2'; } ... (1 Reply)
Discussion started by: mrlayance
1 Replies

3. Shell Programming and Scripting

Perl : embedding java script with cgi perl script

Hi All, I am aware that html tags can be embedded in cgi script as below.. In the same way is it possible to embed the below javascript in perl cgi script ?? print("<form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">"); print("<input type = "text"... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Shell Programming and Scripting

executing perl script from another perl script : NOT WORKING

Hi Folks, I have 2 perl scripts and I need to execute 2nd perl script from the 1st perl script in WINDOWS. In the 1st perl script that I had, I am calling the 2nd script main.pl =========== print "This is my main script\n"; `perl C:\\Users\\sripathg\\Desktop\\scripts\\hi.pl`; ... (3 Replies)
Discussion started by: giridhar276
3 Replies

5. Shell Programming and Scripting

calling a perl script with arguments from a parent perl script

I am trying to run a perl script which needs input arguments from a parent perl script, but doesn't seem to work. Appreciate your help in this regard. From parent.pl $input1=123; $input2=abc; I tried calling it with system("/usr/bin/perl child.pl $input1 $input2"); and `perl... (1 Reply)
Discussion started by: grajp002
1 Replies

6. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

Hi all, Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM. Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers. At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies

7. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

8. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

9. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

10. Shell Programming and Scripting

Perl: Run perl script in the current process

I have a question regarding running perl in the current process. I shall demonstrate with an example. Look at this. sh-2.05b$ pwd /tmp sh-2.05b$ cat test.sh #! /bin/sh cd /etc sh-2.05b$ ./test.sh sh-2.05b$ pwd /tmp sh-2.05b$ . ./test.sh sh-2.05b$ pwd /etc sh-2.05b$ So... (10 Replies)
Discussion started by: vino
10 Replies
Login or Register to Ask a Question