Hi,
I've been banging my head against this problem for a few hours now...
All I want to do is process some log files being created by ntbackup on several servers.
I've got most of the little elements in place, but the main one, grabbing lines with keywords from the log files, is just refusing to work.
It doesn't seem to matter what size the log file is - A couple of lines when a tape fails to load, to a few Mb when doing a full log, findstr refuses to find anything that I ask it to look for in the log file.
A while ago, I gave up and downloaded UnixUtils to use the grep - that does the same thing.
If I delete all bar one or two basic lines from the file it doesn't find anything.
If I rename the file, it doesn't find anything.
If I create a new file and copy some or all of the text from a non-working log file into it, both findstr & grep find the search terms.
If I do 'type original.log > new.log' and then use the same findstr command on the new file - They find the terms
(Strangely, although it contains all of the original text, 'new.log' is exactly half the size of original.log (I've tried it with several different sized logs & the 'type'd version is always exactly half the bytes))
I'm suspecting there's something very basic I should know about the ntbackup log file format - Can anyone tell me what's making findstr & grep bomb-out please?
Many thanks,
Rufus
findstr can't read ntbackup log files
Moderator: DosItHelp
Re: findstr can't read ntbackup log files
It's quite difficult to answer since you didn't show your code.
My assumption so far is that the log files are written in a charset that batch can't read by default (UTF-8, UTF-16 or whatever).
You wrote that TYPE helps. So you could try to pipe the file to FINDSTR.
Reagards
aGerman
My assumption so far is that the log files are written in a charset that batch can't read by default (UTF-8, UTF-16 or whatever).
You wrote that TYPE helps. So you could try to pipe the file to FINDSTR.
Code: Select all
type "file.log"|findstr "keyword"
Reagards
aGerman
Re: findstr can't read ntbackup log files
Half the size? It's in Unicode format I think, and TYPE converts it.
Check the original in a hex editor - almost every second byte will be hex zero.
Check the original in a hex editor - almost every second byte will be hex zero.