findstr can't read ntbackup log files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
RufusMcDoodle
Posts: 1
Joined: 21 Jun 2013 03:40

findstr can't read ntbackup log files

#1 Post by RufusMcDoodle » 21 Jun 2013 03:45

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

aGerman
Expert
Posts: 4743
Joined: 22 Jan 2010 18:01
Location: Germany

Re: findstr can't read ntbackup log files

#2 Post by aGerman » 21 Jun 2013 04:41

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.

Code: Select all

type "file.log"|findstr "keyword"


Reagards
aGerman

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: findstr can't read ntbackup log files

#3 Post by foxidrive » 21 Jun 2013 07:12

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.

Post Reply