This batch needs to check for a string in a log generated by Passmark Burnin,and take action accordingly.If I run this batch on autolog.log,linie.txt returns me "Echo is off".If I copy(manually) the text from autolog to another .log or .txt file,it works perfectly,but I need the batch to work for the original log.I have tried using type and copy to create a second file with the same text in it but it returns a random word,not the 5th on the 13th row(as I skipped for).PS.I have admin rights and that stuff.
"@echo off
Setlocal EnableDelayedExpansion
for /f "skip=12 tokens=5" %%G in (autolog.log) do set "LINE=%%G"
echo %LINE%>linie.txt
findstr /i "3612QE" linie.txt
if errorlevel 1 goto 2
if errorlevel 0 goto 1
goto end
:1
echo gasit
goto end
:2
echo negasit
goto end
:end
pause"
what could be the problem?
thanks
Problem with processing data from an auto-generated log file.
Moderator: DosItHelp
Re: Problem with processing data from an auto-generated log file.
"skip=12" means that the FOR /F loop begins with line 13 but it runs till the end of the file. Variable LINE will be overwritten several times until the end of the file was reached. Thus, the 5th token of the very last line of the file will be saved in this variable. LINE would be not defined if the last line has less than 5 tokens .
Try:
Regards
aGerman
Try:
Code: Select all
set "LINE="
for /f "skip=12 tokens=5" %%G in (autolog.log) do if not defined LINE set "LINE=%%G"
Regards
aGerman
Re: Problem with processing data from an auto-generated log file.
This batch needs to check for a string in a log generated by Passmark Burnin,and take action accordingly.
Code: Select all
findstr /i "3612QE" autolog.log >nul && echo Yep, found the word.
That does what you've asked.
Re: Problem with processing data from an auto-generated log file.
Neither findstr or for /f worked on the auto generated log,but the solution that aGerman gave me worked on a copy of the log.
Thanks everyone for the help.
Thanks everyone for the help.
Re: Problem with processing data from an auto-generated log file.
Maybe the file has the wrong character encoding. Try using TYPE
Regards
aGerman
Code: Select all
for /f "skip=12 tokens=5" %%G in ('type "autolog.log"') do if not defined LINE set "LINE=%%G"
Regards
aGerman