|
| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
URGENT: I need a batch file to ping
|
Original Message
|
Name: sweetnet
Date: January 19, 2006 at 05:50:03 Pacific
Subject: URGENT: I need a batch file to pingOS: Win XP ProCPU/Ram: Pentium M |
Comment: 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
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Mechanix2Go
Date: January 19, 2006 at 09:11:36 Pacific
|
Reply: (edit)Try this: ::== pinglist.bat @echo off > pingresult.txt for /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
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: sweetnet
Date: January 19, 2006 at 23:27:07 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: Mechanix2Go
Date: January 20, 2006 at 23:11:12 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: sweetnet
Date: January 22, 2006 at 21:56:39 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: sweetnet
Date: January 22, 2006 at 23:36:13 Pacific
|
Reply: (edit)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 = 0ms i'm still working on the errorlevel. plz help me.
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: sweetnet
Date: January 23, 2006 at 00:43:06 Pacific
|
Reply: (edit)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 = 0ms C:\>echo %errorlevel% 0
Report Offensive Follow Up For Removal
|
|
Response Number 11
|
Name: Mechanix2Go
Date: January 23, 2006 at 02:46:22 Pacific
|
Reply: (edit)Try this: ::== pingL2.bat @echo off > pingresult.txt for /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=down find /i "reply" < pinglog > nul if not errorlevel 1 set status=up find /i "expired in transit" < pinglog > nul if not errorlevel 1 set status=expired in transit find /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
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Windows XP Forum Home
|
|
|