Pergunta

Sometimes when sending that batch

plink 192.168.X.Y -l Admin -pw password -m C:\vsreset.txt

where vsreset.txt is

POWER reset

I receive some error like

FATAL ERROR .....

I would like to make a batch that retries until "no error found" How can I do this?

I've tried something like this

c:\reset.bat | FIND "ERROR" > NUL
IF ERRORLEVEL 1 resetplus.bat

but I alwais receive errorlevel = 1 and the routines doesn't stop...

Foi útil?

Solução

find returns 1 when it does not find the search string, so you need something like this instead:

@echo off
:repeat
plink 192.168.x.x ... | find "ERROR" >nul
if %errorlevel% equ 0 goto repeat

or shorter:

@echo off
:repeat
plink 192.168.x.x ... | find "ERROR" >nul && goto repeat
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top