Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Text parsing help  (Read 6053 times)

0 Members and 1 Guest are viewing this topic.

zymos

  • Guest
Text parsing help
« on: January 29, 2008, 08:01:31 AM »
Hi all

Got a small problem with parsing texts under XP/Vista/Win2k3.

I know how to find a string in a textfile using FOR or Find but then I only output just that line with text. I need to find a certain string in a text and then output the information in text 2 lines above.

For example:
[2008-01-26 00:27:19.214 'BaseLibs' 1852 warning] SSLVerifyIsEnabled: failed to read registry value. Assuming verification is disabled. LastError = 0
[2008-01-26 00:27:19.214 'BaseLibs' 1852 warning] SSLVerifyCertAgainstSystemStore: Certificate verification is disabled, so connection will proceed despite the error
Converting "x:\vcb-mount\SRV-AXWEB01-fullVM\scsi0-0-0-SRV-AXWEB01.vmdk" (compact file):
        0%=====================50%=====================100%
        ***************[2008-01-26 00:29:13.198 'App' 1852 warning] SanMpAIOMgrRWv: Failed to complete any SCSI IO requests within 200ms.
**********************[2008-01-26 00:33:39.071 'blocklist' 5860 error] Could not renew disk lease. Aborting operation.
[2008-01-26 00:33:44.431 'BlockList' 1852 error]
*************
[2008-01-26 00:33:46.681 'BlockList' 1852 error] The managed object of type "vim.host.DiskManager.Lease" identified by the MoRef "session[6AFEAC02-61FF-4D73-92FD-A542DAE42800]FE1163EB-5D85-4280-A790-FDF5A1D0F0C1" could not be found.

This is from a logfile and i'd like to locate 'Failed to complete' and from there output the line saying 'Converting "x:\\vcb-mount\SRV-AXWEB01-fullVM\scsi0-0-0-SRV-AXWEB01.vmdk" (compact file):' to a new textfile to easier locate where problems occur. And yes, the information in the line that I want to output does change so I can't just find the same string and output it, woul'd have been too easy.  :)
Is there anyone that could help me with a good solution for this?

/Thansk
Zymos

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Text parsing help
« Reply #1 on: January 29, 2008, 12:55:37 PM »
What application produced this log? Is the line you need always two lines prior to your search argument? You could possibly do this in batch or even a Windows script language but try using:

Log Parser. It contains a help file that shows what it can do and how to do it.

Good luck.  8)


The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

zymos

  • Guest
Re: Text parsing help
« Reply #2 on: January 31, 2008, 01:04:57 AM »
It's an output from VM-Ware VCB and yes it's allways 2 lines above the error-line that i need to get out to display what server got the error.

Gonna take a close look at Log Parser but i think it's only usable with Microsofts own logs in windows.

/Z

zymos

  • Guest
Re: Text parsing help
« Reply #3 on: January 31, 2008, 02:12:18 AM »
Maybe there is another approach to the solution? The folder that should contain the backup only contain 1 file when failed. Is there a way to check a number of folders for amount of files and if only 1 file is found in a folder then display the folder name?

Example:
folder X:\vcb-mount\ contains all folders with servernames that contains backups
folder X:\vcb-mount\servername1 contains multiple files = backup ok
folder X:\vcb-mount\servername2 contains 1 file = backup not ok so put the foldername for this folder into error.txt

Can this maybe be done easier?

/Z

ghostdog74



    Specialist

    Thanked: 27
    Re: Text parsing help
    « Reply #4 on: January 31, 2008, 03:12:39 AM »
    Maybe there is another approach to the solution?
    ...
    Can this maybe be done easier?

    yes there is. The other approach is to use tools like GNU grep.. Then you can use it in your batch like
    Code: [Select]
    grep -B 2 "Failed to complete" errorfile > outfile

    gpl



      Apprentice
    • Thanked: 27
      Re: Text parsing help
      « Reply #5 on: January 31, 2008, 03:38:01 AM »
      zymos
      it works on virtually any log - application and iis, the file system, active directory, csv and tab separated format -- and it those all fail, any text format file
      Graham

      zymos

      • Guest
      Re: Text parsing help
      « Reply #6 on: January 31, 2008, 06:16:23 AM »
      Just got grep for windows installed as ghostdog74 recommended and got exactly what i needed. Thanks all for good and fast reply's.

      Z