I have a batch script where I want to run a particular command (which outputs a status) until its output contains a particular keyword. I'm not sure either of how to loop like this in a batch script nor of how to save and parse the output of a command.
I've tried an approach as described in Raymond Chen's "Reading the output of a command into a batch file variable" (which uses a for loop to parse command output), without success (it's quite possible that I'm simply mangling or misunderstanding the commands). Any suggestions for how to repeat a command, parse its output, and repeat until the output is acceptable?
no need to put the output into a variable for this. Just:
:loop
timeout /t 1 >nul
command | find "this is what I want"
if errorlevel 1 goto :loop
echo successful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With