Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a batch file to ping a list of ip from a source file(iplist.txt)written like this:
-----------------
0.0.0.0, host1, note
1.1.1.1, host2, note
2.2.2.2, host3, note
-----------------
i just want to get a result written like this in (pingresult.txt):0.0.0.0 , host1 , note, time ,up
1.1.1.1 , host2 , note, time ,down
2.2.2.2 , host3 , note, time ,up
plz can anyone help me

Try this:
::== pinglist.bat
@echo off > pingresult.txtfor /f "tokens=* delims=," %%I in (IPlist.txt) do call :sub1 %%I
goto :eof:sub1
set status=up
ping %1 |find /i "reply" > nul
if errorlevel 1 set status=down
>> pingresult.txt echo %* , %TIME%, %status%
goto :eof
:: DONE
If at first you don't succeed, you're about average.M2

The second line starts with for and ends with %%I; but it got wrapped here.
If at first you don't succeed, you're about average.M2

thanks for the replay,
i try your code, the result:
- for the ip that i confirm up (i reconfirm by manually ping in DOS) the status in pingresult.txt is = up
- but for the ip that i confirm "expired in transmit" (i reconfirm by manually ping in DOS) the status in pingresult.txt is also = up.
is there is a way where we can come out for a result like this
----------
0.0.0.0,host1, note, time, up
1.1.1.1,host2, note, time, expired in transit
2.2.2.2,host3, note, time, up
3.3.3.3,host4, note, time, down----------
in this situation i consider the ip with ping result = expired in transit or request time out as down.
kindly assist me.

Hi,
I have not recieved the "expired in transit" result so I don't know the complete output or the result code.
If you have an IP which will give that result, post the out put. And do this and let me know the errorlevel number:
echo %errorlevel%
If at first you don't succeed, you're about average.M2

Hi,
thanks, i'll try my best to present you the output and the errorlevel. it might take sometimes coz im not verry good in batch programming.
kind wait for my reply.

hai,
this is a ping result from my LAN ip which i consider as down:
C:\Documents and Settings\Administrator>ping 10.212.196.193
Pinging 10.212.196.193 with 32 bytes of data:
Reply from 10.226.217.98: TTL expired in transit.
Reply from 10.226.217.98: TTL expired in transit.
Reply from 10.226.217.98: TTL expired in transit.
Reply from 10.226.217.98: TTL expired in transit.Ping statistics for 10.212.196.193:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0msi'm still working on the errorlevel.
plz help me.

Just after the ping stops, do this:
echo %errorlevel%
[enter]
If at first you don't succeed, you're about average.M2

hi,
here is the result you requested:
C:\>ping 10.217.215.65
Pinging 10.217.215.65 with 32 bytes of data:
Reply from 10.226.217.102: TTL expired in transit.
Reply from 10.226.217.102: TTL expired in transit.
Reply from 10.226.217.102: TTL expired in transit.
Reply from 10.226.217.102: TTL expired in transit.Ping statistics for 10.217.215.65:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0msC:\>echo %errorlevel%
0

Try this:
::== pingL2.bat
@echo off > pingresult.txtfor /f "tokens=* delims=," %%I in (IPlist.txt) do call :sub1 %%I
goto :eof:sub1
ping %1 > pinglog
find /i "unknown host" < pinglog > nul
if not errorlevel 1 set status=downfind /i "reply" < pinglog > nul
if not errorlevel 1 set status=upfind /i "expired in transit" < pinglog > nul
if not errorlevel 1 set status=expired in transitfind /i "Request timed out" < pinglog > nul
if not errorlevel 1 set status=down>> pingresult.txt echo %*, %TIME%, %status%
goto :eof
:: DONE
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |