Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Ping in a Batch FIle

575 views
Skip to first unread message

Joe

unread,
Apr 28, 2001, 2:40:03 AM4/28/01
to
I am looking for some help with creating a batch file to ping IP
numbers and giving options if the IP fails and if the IP is good.
For example ping 127.0.0.1 and if it is good it offers to ping the
next IP 127.0.0.2 and then if that one is bad it would run a batch
file saying to call tech support.
So if anyone can help me create a batch file to do this it would be
great.
Thanx in advance

Rob van der Woude

unread,
Apr 28, 2001, 6:53:06 AM4/28/01
to
Hi Joe,

For a "closed" range of IP addresses use FOR /L:

FOR /L %%A IN (1,1,254) DO CALL :Check 10.0.0.%%A
FOR /L %%A IN (1,1,254) DO CALL :Check 10.0.1.%%A
GOTO:EOF

Otherwise, create a file called addresses.lst and use FOR /F:

FOR /F %%A IN (addresses.lst) DO CALL :Check %%A
GOTO:EOF

The :Check subroutine could be something like this:

:Check
PING %1 | FIND "TTL=" >NUL
IF ERRORLEVEL 1 (CALL WarnTechSupport.bat) ELSE (ECHO %1 is on
the air)
GOTO:EOF

(Command lines are indented by a TAB or 5 spaces, if not the line is
the continuation of the previous line).
This batch file does NOT stop at every IP address that's OK, if you
want that replace the "ELSE part".
Good luck,

Rob van der Woude

Joe <.dc...@hotmail.com> wrote in
<rcpket42svmqr0fqo...@4ax.com>:

--
-----------------------------
Rob van der Woude
http://www.robvanderwoude.com

0 new messages