473,512 Members | 15,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Parsing via PERL Scripting

3 New Member
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
4 1845
DjLethal
3 New Member
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
971 Recognized Expert Contributor
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
DjLethal
3 New Member
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
4,059 Recognized Expert Specialist
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

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

Similar topics

14
2550
by: Xah Lee | last post by:
Just bumped into another irresponsibility in perl. the crime in question this time is the module File::Basename. Reproduction: 1. create a directory containing a file of this name:...
1
17513
by: Scott | last post by:
I am new to perl, and have not found any good examples of parsing to help me out. I have a text file that I am reading into an array that has to be parsed out and put into another file. I have not...
8
4418
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
13
6195
by: James | last post by:
Hello, I'm a newbie to Python & wondering someone can help me with this... I have this code: -------------------------- #! /usr/bin/python import sys
4
2044
by: Epictitus | last post by:
I am trying to write a script which will allow me to read the contents of an HTTP web page into memory, parse the data, and output a calculated value. The HTTP page is on a web enable appliance -...
5
2324
by: moddster | last post by:
Hi Guys. I am a newbie to perl and need some help with a problem. PROBLEM: I have to parse an HTML file and get rid of all the HTML tags and count the number of sumbissions a person has through...
5
2390
by: beginnerperl | last post by:
Hello All, I am writing a perl program that pars through a text file and find a particular word and reverse the word. I can do that fine, but when creating the output file, the output files gives me...
3
3082
by: sainiamit25 | last post by:
Hi, I am trying to set up environment for XML parsing using perl. I downloaded XML::Simple and installed it too. When i try to run my program, it says, you need to install parser. When i try to...
13
2008
by: Adhal | last post by:
Hi, How can I stop hotlinking to a specific file, and I want it to redirect it to a PHP link so I can monitor the number of downloads. Here is my site with the download page:...
0
7371
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.