Reputation: 396
I'm trying to compare an empty string to the results from a ping using FIND
. I want to capture only failed ping requests.
Here's what I've tried so far:
ping -n 1 %choice% | FIND "Request" >> %request%
FOR /F "delims=" %%a in ('ping -n 1 %choice% | FIND "Request") Do @set request =%a
Once I get this to set correctly, I plan to compare request
to an empty string.
Upvotes: 0
Views: 52
Reputation: 5883
You need to protect the pipe, and have matched quotes in the for command, and use %%:
FOR /F "delims=" %%a in ('ping -n 1 %choice% ^| FIND "Request" ') Do @set request =%%a
Upvotes: 1
Reputation: 41224
Test this:
ping -n 1 %choice% | FIND "TTL=">nul && (echo pass) || (echo fail)
pause
Upvotes: 2