Edit bat file to parse strings and send output to file
Posted: 02 Feb 2021 12:49
Hi all,
I have a batch file that pings a list of IP addresses. I need to send only the failed pings to a file.
Here's the batch file:
@Echo OFF
For /F "Usebackq Delims=" %%# in (
"List.txt"
) do (
Echo+
Echo [+] Pinging: %%#
Ping -n 1 "%%#" 1>nul && (
Echo [OK]) || (
Echo [FAILED])
)
Pause&Exit
The output looks like this, just showing two for example:
[+] Pinging: 172.17.219.133
[FAILED]
[+] Pinging: 172.28.145.199
[OK]
I need to edit the batch file to send the lines with the IP address of the failed pings to a file.
Is this possible?
Thanks in advance for your time and advice,
Eric
I have a batch file that pings a list of IP addresses. I need to send only the failed pings to a file.
Here's the batch file:
@Echo OFF
For /F "Usebackq Delims=" %%# in (
"List.txt"
) do (
Echo+
Echo [+] Pinging: %%#
Ping -n 1 "%%#" 1>nul && (
Echo [OK]) || (
Echo [FAILED])
)
Pause&Exit
The output looks like this, just showing two for example:
[+] Pinging: 172.17.219.133
[FAILED]
[+] Pinging: 172.28.145.199
[OK]
I need to edit the batch file to send the lines with the IP address of the failed pings to a file.
Is this possible?
Thanks in advance for your time and advice,
Eric