1.

Solve : Text parsing help?

Answer»

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
ZymosWhat 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.


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.

/ZMaybe 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?

/ZQuote from: zymos on January 31, 2008, 02:12:18 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
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
GrahamJust got grep for windows installed as ghostdog74 recommended and got exactly what i needed. Thanks all for good and FAST reply's.

Z


Discussion

No Comment Found