If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Parse a file for different messages...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-04, 04:51
debkumar debkumar is offline
Registered User
 
Join Date: May 2002
Posts: 28
Parse a file for different messages...

My Requirement is i have a file from where i will have to pick up the Queue which is having message> 0 (like for eg. ERRORS : 2 , SOURCE_XREF : 1) and associated QSPACE i.e. QSPACE = [ EXCEPTIONS ]. (also see the eg. below)

The file is like

Queues in QSPACE = [ EXCEPTIONS ]

------------------------------------------------------------------

Queue EXCEPTIONS : 0 Persistent Messages using 0 pages.

Queue ERRORS : 2 Persistent Messages using 2000pages.

Queue CLIENT_ERRORS : 0 Persistent Messages using 0pages.



Queues in QSPACE = [ SOURCE_XREF ]

--------------------------------------------------------------

Queue SOURCE_XREF : 1 Persistent Messages using 1000 pages.

Queue ERRORS : 0 Persistent Messages using 0 pages.



Queues in QSPACE = [ DEL_NTPA_MERVA ]

---------------------------------------------------------------------

Queue PAYMENTS : 3 Persistent Messages using 3000 pages.

Queue NON_PAYMENTS : 0 Persistent Messages using 0 pages.

Queue ERRORS : 0 Persistent Messages using 0 pages.



Queues in QSPACE = [ REC_NTPA_MERVA ]

---------------------------------------------------------------------

Queue PAYMENTS : 0 Persistent Messages using 0 pages.

Queue NON_PAYMENTS : 0 Persistent Messages using 0 pages.



Queues in QSPACE = [ XFM_MERVA_NTPA ]

---------------------------------------------------------------------

Queue MESSAGES : 1 Persistent Messages using 1000 pages.

Queue REPLIES : 0 Persistent Messages using 0 pages.

Queue ERRORS : 0 Persistent Messages using 0 pages.



Queues in QSPACE = [ XFM_NTPA_MERVA ]

-----------------------------------------------------------------------

Queue PAYMENTS_FO : 0 Persistent Messages using 0 pages.

Queue NON_PAYMENTS_FO : 0 Persistent Messages using0 pages.

Queue REPLIES_FO : 3 Persistent Messages using 3000 pages.

Queue PAYMENTS_MQ : 0 Persistent Messages using 0 pages.

Queue NON_PAYMENTS_MQ : 5 Persistent Messages using 5000 pages.







If there is any Queue that is having messages > 0 than you have to print the Queues in QSPACE and associated Queue .

As for example here u have toshow only

Queues in QSPACE = [ EXCEPTIONS ]

Queue ERRORS : 2 Persistent Messagesusing 2000 pages.



Queues in QSPACE = [ SOURCE_XREF ]

Queue SOURCE_XREF : 1 PersistentMessages using 1000 pages.



Queues in QSPACE = [ DEL_NTPA_MERVA ]

Queue PAYMENTS : 3 Persistent Messages using 3000 pages.



Queues in QSPACE = [ XFM_MERVA_NTPA ]

Queue MESSAGES : 1 Persistent Messages using 1000 pages.



Queues in QSPACE = [ XFM_NTPA_MERVA ]

Queue REPLIES_FO : 3 Persistent Messages using 3000 pages.

Queue NON_PAYMENTS_MQ : 5 Persistent Messages using 5000 pages.
Reply With Quote
  #2 (permalink)  
Old 01-08-04, 12:49
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Hi,
this script is what you ask for. Look at the end for the output which is given. I think DaminanI... or another guy can tell us how to change the whileloops into for/next Loops. Then the script will be get more elegance.

cat errorfile | awk ' BEGIN { FS=" "
last_sec="INIT"
errno=0
##### clear array
##### possible errors/section 10
i=0
while (i != 10)
{
array[i]=""
i=i+1
}
}
##### beginning
{
if ($3 == "QSPACE" )
{
section=$0
if (section != last_sec)
# new section found
{
##### print array
i=0
while (i != 10)
{
if (array[i] > "")
{
print array [i]
}
i=i+1
}
##### clear array
i=0
while (i != 10)
{
array[i]=""
i=i+1
}
##### make two empty lines between sektions
if (errno > 1)
{
print " "
print " "
}
last_sec=section
array[0]=section
array[1]="################################################ #####"
errno=1
}
}
if ($3 == ":")
##### error line found
{
if ($4 > "0")
##### error found
{
errno=errno+1
array[errno]=$0
}
}
} END {
##### print last entry
i=0
while (i != 10)
{
if (array[i] > "")
{
print array [i]
}
i=i+1
}
}'

OUTPUT for example:

Queues in QSPACE = [ EXCEPTIONS ]
##############################################
Queue ERRORS : 2 Persistent Messages using 2000pages.


Queues in QSPACE = [ SOURCE_XREF ]
##############################################
Queue SOURCE_XREF : 1 Persistent Messages using 1000 pages.
Queue CLIENT_ERRORS : 1 Persistent Messages using 0pages.


Queues in QSPACE = [ DEL_NTPA_MERVA ]
##############################################
Queue ERRORS : 1 Persistent Messages using 0 pages.
__________________
Greetings from germany
Peter F.

Last edited by fla5do; 01-08-04 at 13:52.
Reply With Quote
  #3 (permalink)  
Old 01-09-04, 13:02
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
in this row is a mistake.
array[1]="#################################

a doublequote at the end of the line is missing
array[1]=" #################################"
__________________
Greetings from germany
Peter F.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On