Search Multiple Different Errors & Assign Variables in batch

May 11, 2012 at 15:53:15
Specs: Windows 2003
Hi Gurus,

I'm trying to write a bat script which will loop through a text file & search multiple different type of messages and assign variable to each type of message. The txt file may content 3 types of messages: Success, Error, & Fails.

Here is the condition: I may have a success & error at the same time in the file. So, if it found both of them, then set the status==error. If it found only success, set status==success; otherwise, if it found fails, set status==fails.

for /f "token=*" %%a IN (C:\testfile.txt) DO (
'FINDSTR /i /m "successfully loaded/unloaded" C:\testfile.txt if exist set %status%==Success',
'FINDSTR /i /m "Error" AND "successfully loaded/unloaded" C:\testfile.txt if exist set %status%==Error',
'FINDSTR /i /m "Fails" C:\testfile.txt if exist "Fails" set %status%==Fails'
)

Please helps.......

Thanks,
-Daigia


See More: Search Multiple Different Errors & Assign Variables in batch

Report •


#1
May 13, 2012 at 08:50:25
try this..


@echo off
SetLocal ENABLEDELAYEDEXPANSION
set status=Error
for /f "token=*" %%a in ('find /i /c "sucessfully"') do
if "%%a" GEQ "1" set !status!=Success
Endlocal


Report •

#2
May 14, 2012 at 09:24:49
Thx for a response, but this only solves the problem w/ success & failure. I have a case that the job is successful but has some errors, Not a fails job. It just completed w/ errors and I'm trying to capture this scenario in the codes. Any helps/ideas are appreciated.

Thanks.
-Daigia


Report •
Related Solutions


Ask Question