By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,847 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,847 IT Pros & Developers. It's quick & easy.

File Parsing via PERL Scripting

P: 3
Hey Guys.I am a newbie on Perl.And I have a question about file parsing by perl.
I have a log file which contains reports about a communication machine.I need to take some of the reports from the log file.Its hard to explain the issue.but shortly I can say that the reports has a unique report no. and this report number is located at the 3rd line and at the end of the report.How can I parse these reports?(I need all of the lines like below.)
It is very important for me.I am waiting for your fast response
Thanking you in advanced.

For Example:

Expand|Select|Wrap|Line Numbers
  1. INITSX1                      2008-02-07  15:46:00  TH      
  2.     PSW001    0130/000C/0005  
  3.     SEQ=7734+2007-12-31 00104  00000000   M147AA03   M1SNSK04    
  4.     SWA-CE LOAD                                                     
  5.  
  6.        ACTIVATE-CEOVLD-OBSERV                                         SUCCESSFUL
  7.                                                            RESULT    PART 0001 -
  8.        -------------------------------------------------------------------------
  9.        REQUESTED START TIME: = 15:30
  10.        REQUESTED STOP TIME : = 15:45
  11.        PERIOD: = 00:15
  12.  
  13.        NO PROCESSORS IN OVERLOAD  
  14.  
  15.        REPORT FOLLOWS       NO = 00104
Feb 25 '08 #1
Share this Question
Share on Google+
4 Replies


P: 3
And a tiny part of the log is at the below:
Expand|Select|Wrap|Line Numbers
  1.   INITSX1           2008-02-07  14:57:08  TH      
  2.     PSW010    0130/000C/0004  
  3.     SEQ=8323.2008-02-07 00098  00000000   M147AA03   M1SNSK04    
  4.     SWA-SUBSEC ROUTING                                              
  5.  
  6.        EXTEND-TKG                                                     SUCCESSFUL
  7.                                                            FINAL   RESULT 0006 -
  8.        -------------------------------------------------------------------------
  9.        DETAIL   = NORM                           
  10.        TRUNKS RELEASED
  11.  
  12.        TKG                    TKSEQ TCESEQ STATE    FIFO   OBSERV
  13.        LCEID    NA       LAN  TN/TS        TRAFFIC  GLARE  CONTCHK
  14.        -------- ------------ ------ ------ -------- ------ -------------
  15.        HDR1AFM5B07_4014        4423      4 BLOCKED  TRUE   REMOVE
  16.        H'A480   H'C21F    23     23        TRAL     TRUE   NCONTCHK
  17.        -------- ------------ ------ ------ -------- ------ -------------
  18.        HDR1AFM5B07_4014        4424      4 BLOCKED  FALSE  REMOVE
  19.        H'A480   H'C21F    23     24        TRAL     FALSE  NCONTCHK
  20.        -------- ------------ ------ ------ -------- ------ -------------
  21.        HDR1AFM5B07_4014        4425      4 BLOCKED  TRUE   REMOVE
  22.        H'A480   H'C21F    23     25        TRAL     TRUE   NCONTCHK
  23.        -------- ------------ ------ ------ -------- ------ -------------
  24.        HDR1AFM5B07_4014        4426      4 BLOCKED  FALSE  REMOVE
  25.        H'A480   H'C21F    23     26        TRAL     FALSE  NCONTCHK
  26.        -------- ------------ ------ ------ -------- ------ -------------
  27.        HDR1AFM5B07_4014        4427      4 BLOCKED  TRUE   REMOVE
  28.        H'A480   H'C21F    23     27        TRAL     TRUE   NCONTCHK
  29.        -------- ------------ ------ ------ -------- ------ -------------
  30.        HDR1AFM5B07_4014        4428      4 BLOCKED  FALSE  REMOVE
  31.        H'A480   H'C21F    23     28        TRAL     FALSE  NCONTCHK
  32.        -------- ------------ ------ ------ -------- ------ -------------
  33.        HDR1AFM5B07_4014        4429      4 BLOCKED  TRUE   REMOVE
  34.        H'A480   H'C21F    23     29        TRAL     TRUE   NCONTCHK
  35.        -------- ------------ ------ ------ -------- ------ -------------
  36.        HDR1AFM5B07_4014        4430      4 BLOCKED  FALSE  REMOVE
  37.        H'A480   H'C21F    23     30        TRAL     FALSE  NCONTCHK
  38.        -------- ------------ ------ ------ -------- ------ -------------
  39.        HDR1AFM5B07_4014        4431      4 BLOCKED  TRUE   REMOVE
  40.        H'A480   H'C21F    23     31        TRAL     TRUE   NCONTCHK
  41.        -------- ------------ ------ ------ -------- ------ -------------
  42.  
  43.        LAST REPORT          NO = 00098
  44.  
  45.               
  46.  
  47.     INITSX1           2008-02-07  14:57:50  TH      
  48.     PSW010    0402/000C/1014  
  49.     SEQ=8308.2008-02-07 00462  00000000   M147AA03   M1SNSK04    
  50.     SWA-MONITORING                                                  
  51.  
  52.        START-MPTMON                                                      ABORTED
  53.        -------------------------------------------------------------------------
  54.        PHYSDEV  =  00402/000C/03F6
  55.  
  56.  
  57.        LAST REPORT          NO = 00462
  58.  
  59.               
  60.  
  61.     INITSX1           2008-02-07  14:57:38  TH      
  62.  
  63.                             00048  00000000   M147AA03   M1SNSK04    
  64.     ANOMALY REPORT
  65.  
  66.        ERROR TYPE    1531  CS_MW_COMM_FLT                          SYSTEM REPORT
  67.        -------------------------------------------------------------------------
  68.        57:38:08        NA = 8507
  69.        ERCLAS SEQ RLVL FMM   PROC  CS : IP  USERDATA
  70.        NOTIFY 18  NONE 5005  1C30 15A8:9379 D0 A1 12 24 FF FF FF FF 00 00
  71.  
  72.        UNSOLICITED REPORT   NO = 00048
  73.  
  74.               
  75.  
  76.     INITSX1           2008-02-07  14:59:59  TH      
  77.     PSW001    0130/000C/0005  
  78.     SEQ=7734+2007-12-31 00104  00000000   M147AA03   M1SNSK04    
  79.     SWA-CE LOAD                                                     
  80.  
  81.        ACTIVATE-CEOVLD-OBSERV                                         SUCCESSFUL
  82.                                                            RESULT    PART 0001 -
  83.        -------------------------------------------------------------------------
  84.        REQUESTED START TIME: = 14:45
  85.        REQUESTED STOP TIME : = 15:00
  86.        PERIOD: = 00:15
  87.  
  88.        NO PROCESSORS IN OVERLOAD  
  89.  
  90.        REPORT FOLLOWS       NO = 00104
  91.  
  92.               
  93.  
  94.     INITSX1           2008-02-07  15:00:00  TH      
  95.  
  96.                             06039  00000000   M147AA03   M1SNSK04    
  97.     SWA-#7 MTP                                                      
  98.  
  99.                                                                    SYSTEM REPORT
  100.        -------------------------------------------------------------------------
  101.          N7 MTP
  102.          N7 MSU DISCARD REPORT / N7 MEASUREMENTS FIRST AND INTERVAL REPORTING
  103.          INFO: NO INFO                    REPORT PERIOD: 14:55 - 15:00
  104.          OWN IDENTIFICATION: SIR2710T           NW: LOGNET_NAT0_ITU 
  105.          ----------------#----------------#--------#---#-----#-----#-----
  106.             ADJACENT             NW          LINK   SLC Q.752 EVENT  NBR
  107.             DESTINATION                      SET                     MSU
  108.          ----------------#----------------#--------#---#-----#-----#----- 
  109.           35 102          S_MOB            S_KOST33   0  5.5    12     40
  110.           35 102          S_MOB            S_KOST33   1  5.5    12     55
  111.           26 102          S_MOB            S_BRKO33   1  5.5    12      4
  112.           35 103          S_MOB            S_MVST33   0  5.5    12     38
  113.           35 103          S_MOB            S_MVST33   1  5.5    12     53
  114.           35 102          C_MOB            C_KOST33   3  5.5    12     32
  115.           35 103          C_MOB            C_MVST33   2  5.5    12     32
  116.           35 103          C_MOB            C_MVST33   0  5.5    12     16
  117.           35 102          C_MOB            C_KOST33   1  5.5    12     17
  118.           35 103          C_MOB            C_MVST33   1  5.5    12     17
  119.           35 102          C_MOB            C_KOST33   0  5.5    12     12
  120.  
  121.         EVENT + MEANING
  122.         ------+---------------------------------------------------- 
  123.           12    NO TUP OR ISUP DESTINATION LCE FOUND FOR THIS CIC   
  124.  
  125.        UNSOLICITED REPORT   NO = 06039
  126.  
  127.               
  128.  
  129.     INITSX1           2008-02-07  15:00:00  TH      
  130.  
  131.                             05254  00000000   M147AA03   M1SNSK04    
  132.     SWA-CHARGING OUTPUT                                             
  133.  
  134.                                                                          WARNING
  135.                                                                   FINAL   RESULT
  136.        -------------------------------------------------------------------------
  137.        FILES-DETBIL-THRESHOLD                                   
  138.  
  139.          CALLTYP                          :     DORABS  
  140.          TOTAL NUMBER OF FILES            :     1    
  141.          NUMBER OF BUSY FILES             :     0    
  142.        ---------------------------------------------------------------------- 
  143.        DIVISION OF REVENUE FILE MUST BE EMPTIED                 
  144.  
  145.        UNSOLICITED REPORT   NO = 05254
  146.  
  147.               
  148.  
  149.     INITSX1           2008-02-07  15:00:00  TH      
  150.  
  151.                             05254  00000000   M147AA03   M1SNSK04    
  152.     SWA-CHARGING OUTPUT                                             
  153.  
  154.                                                                          WARNING
  155.                                                                   FINAL   RESULT
  156.        -------------------------------------------------------------------------
  157.        FILES-DETBIL-THRESHOLD                                   
  158.  
  159.          CALLTYP                          :     OMBBB   
  160.          TOTAL NUMBER OF FILES            :     1    
  161.          NUMBER OF BUSY FILES             :     0    
  162.        ---------------------------------------------------------------------- 
  163.        BULK BILLING FILE MUST BE EMPTIED                        
  164.  
  165.        UNSOLICITED REPORT   NO = 05254
  166.  
  167.               
  168.  
  169.     INITSX1           2008-02-07  15:00:11  TH      
  170.  
  171.                             06038  00000000   M147AA03   M1SNSK04    
  172.     SWA-#7 MTP                                                      
  173.  
  174.                                                                    SYSTEM REPORT
  175.        -------------------------------------------------------------------------
  176.          N7 MTP
  177.          N7 MSU DISCARD REPORT / N7 MEASUREMENTS FIRST AND INTERVAL REPORTING
  178.          INFO: NO INFO           FIRST REPORT OF PERIOD: 15:00 - 15:05  
  179.                                              TIMESTAMP: 15:00:01
  180.          OWN IDENTIFICATION: SIR2710T           NW: LOGNET_NAT0_ITU 
  181.          ----------------#----------------#--------#---#-----#---#----------------------------------------------------
  182.             ADJACENT             NW          LINK   SLC Q.752 EVT                    MSU CONTENTS
  183.             DESTINATION                      SET        TAB         OPC      DPC    SSF SI      HEX DUMP AFTER OPC
  184.          ----------------#----------------#--------#---#-----#---#--------=--------=---=---=-------------------------- 
  185.           35 103          S_MOB            S_MVST33   0  5.5   12 H'001C8B H'000A78   8   5 1 58 06 17 01 01 07   
  186.           35 103          S_MOB            S_MVST33   1  5.5   12 H'001C8B H'000A78   8   5 8 E1 05 12            
  187.           26 102          S_MOB            S_BRKO33   1  5.5   12 H'000A1B H'000A78   8   5 1 61 00 17 01 01 1E   
  188.           35 102          S_MOB            S_KOST33   0  5.5   12 H'001C8B H'000A78   8   5 6 22 06 12            
  189.           35 102          S_MOB            S_KOST33   1  5.5   12 H'001C8B H'000A78   8   5 B 41 06 12            
  190.  
  191.         EVENT + MEANING
  192.         ------+---------------------------------------------------- 
  193.           12    NO TUP OR ISUP DESTINATION LCE FOUND FOR THIS CIC   
  194.  
  195.        UNSOLICITED REPORT   NO = 06038

Feb 25 '08 #2

eWish
Expert 100+
P: 971
Please show us what you have tried. Also, please read the "Guidelines To Ensuring Better Answers and Assistance To Your Thread(s)"

--Kevin
Feb 25 '08 #3

P: 3
cat <log file name> | grep 00104 > xxx.txt

I could find lines which has the report numbers but also i need the lines between the report numbers.This is my question for now.
Feb 25 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
cat <log file name> | grep 00104 > xxx.txt

I could find lines which has the report numbers but also i need the lines between the report numbers.This is my question for now.
If you want to know how to do it with something besides perl I recommend you ask on www.unix.com in the shell scripting forum. There are many awk, nawk, sed, sh, ksh, etc etc etc coders there that can help you.

http://www.unix.com/shell-programming-scripting/

If you want to know how to do it with perl you will need to start writing some perl and we will try and help, what we don't do here on this forum is write your code for you. But the unix forum above will.
Feb 25 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.