Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    28

    Unanswered: 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.

  2. #2
    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.
    Last edited by fla5do; 01-08-04 at 14:52.
    Greetings from germany
    Peter F.

  3. #3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •