Timeout via for loop

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
A_Bobby
Posts: 38
Joined: 21 Oct 2010 12:48

Re: Timeout via for loop

#16 Post by A_Bobby » 21 Nov 2022 15:49

I ran the code within the script but could not get what I wanted. So I created a separate snippet of the code you gave below and unremmed it. I ran it against the attached bug report after I introduced false positives from the errorlist.txt in the log file, but i go the following output (edited). It goes through all the strings but comes up empty in terms of spitting out what it found. And regardless of what it finds or not, it displays errors found error message.
Here's your code snipped. Had to fix couple of typos from the original. Extra ' in front of 2 and missing % for %a.

Code: Select all

rem @echo off
rem setlocal enabledelayedexpansion
set "err="
for /f "delims=|" %%a in (errorlist.txt) do (
  for /f "delims=|" %%b in ('2^>nul findstr /C:"%%a" "%cd%\Logs\*.*"') do (
    set "err=1"
    set "str=%%b"
    setlocal EnableDelayedExpansion
    echo !str:~0,-1!
    endlocal
  )
)
if defined err goto :errordisplay

:errordisplay
@echo errors found
C:\Users\Bobby\AppData\Local\Android\Sdk\platform-tools>(for /F "delims=|" %b in ('2>nul findstr /C:"BERR_OUT_OF_DEVICE_MEMORY " "C:\Users\Bobby\AppData\Local\Android\Sdk\platform-tools\Logs\*.*"') do (
set "err=1"
set "str=%b"
setlocal EnableDelayedExpansion
echo !str:~0,-1!
endlocal
) )

C:\Users\Bobby\AppData\Local\Android\Sdk\platform-tools>(for /F "delims=|" %b in ('2>nul findstr /C:"ERROR! Hasn't enough continuous memory in memoryPool " "C:\Users\Bobby\AppData\Local\Android\Sdk\platform-tools\Logs\*.*"') do (
set "err=1"
set "str=%b"
setlocal EnableDelayedExpansion
echo !str:~0,-1!
endlocal
) )

C:\Users\Bobby\AppData\Local\Android\Sdk\platform-tools>(for /F "delims=|" %b in ('2>nul findstr /C:"isImpairment: 1 " "C:\Users\Bobby\AppData\Local\Android\Sdk\platform-tools\Logs\*.*"') do (
set "err=1"
set "str=%b"
setlocal EnableDelayedExpansion
echo !str:~0,-1!
endlocal
) )

C:\Users\Bobby\AppData\Local\Android\Sdk\platform-tools>if defined err goto :errordisplay
errors found
Attachments
stb1.zip
(1.04 MiB) Downloaded 114 times

Post Reply