Findstr suggestions

Microsoft Windows xp professional w/serv...
September 2, 2009 at 06:38:49
Specs: Windows XP, N/A
Here is my very modest Findstr batch file, which I use to locate certain info from remote machines. I've ran into an issue though, as the logs I examine have 2 seperate data sources which make up the log. I want to find a way to dispaly both parts of the feed through entering only a few pieces of information.

@echo off

echo "enter machine"
set /p machine=

echo"which log do you want to query?"
set/p log_name=

echo"what order do you want to look for"
set/p order_number=

psexec \\%machine%\d$\tmi\mfws\logs

findstr /i %order_number% %log_name% > c:\desktop\output1.txt

** this works and returns a text file with appropriate info **

My issue is that within the one log I have 2 seperate feeds which enter it. One feed gives me an accurate time stamp in local time (Australian Time), the other feed has a time stamp which is in UTC, and is not accurate, however this feed contains all the important info. Example of how they look.

[22:30:10:555 25/09/09: Session began host process starting- recieved msg]


The two are always bunched together, but sit in the log on seperate lines. Is there any way I can use findstr (or any other DOS command) to capture the line of text which preceeds my result.


Findstr /i 35=D LOG01

would return the whole line (8=FIX4.0;35=D;44=66666;122=12:30 ......

Is there anyway I can also retreive the line before, in PROC begining with [22:30:10:555 25/09/09: Session began .... using a dos command.

I cant use any form a calculation to convert the times in LOG01 to PROC as the LOG01 time stamp is not accurate.

Please anyone tell me if I'm making this clear or if I'm being dumb. Help would be very much appreciated.

Thanks for reading

See More: Findstr suggestions

Report •

September 3, 2009 at 04:26:09
I figure is this what you want:

del c:\desktop\output.txt
findstr /c:"Session began host" log01.txt>>c:\desktop\output.txt
findstr "35=D" log01.txt>>c:\desktop\output.txt

It assumes that the string "Session began host" is always present in the log file.

Report •
Related Solutions

Ask Question