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

how to ping a list of IPs and return a message

273 views
Skip to first unread message

Tim Baker

unread,
Jun 9, 2004, 6:04:15 AM6/9/04
to
HI,
I would like to use a batch file in combination with a text lookup file to
check to see if a number of IP addresses are currently responding.
Using a text file containing a list of IPs and names, such as

192.168.1.1,My Webpage
216.239.59.99,Google
10.0.0.12,Network Printer

I would like to ping the IPs, and print a message depending on whether the
IP responds or not, eg

c:\>go.bat
My Webpage is up
Google is up
Network Printer is down

Is this possible, and is there an easier way of doing this than a batch
file?

Thanks in advance,
Tim


Marco Maier

unread,
Jun 9, 2004, 6:24:35 AM6/9/04
to
Tim Baker wrote in message <news:10cdo50...@corp.supernews.com> :

Try this one:

@echo off
for /f "delims=, tokens=1*" %%a in ('type a.txt') do (
ping %%a|find "TTL">nul
if not errorlevel 1 (echo %%b : UP) else (
echo %%b : Down))

Tim Baker

unread,
Jun 9, 2004, 7:06:19 AM6/9/04
to

"Marco Maier" <marcomaie...@Myahoo.it> wrote in message
news:17oyrwwj...@MIR.SID...

>
> Try this one:
>
> @echo off
> for /f "delims=, tokens=1*" %%a in ('type a.txt') do (
> ping %%a|find "TTL">nul
> if not errorlevel 1 (echo %%b : UP) else (
> echo %%b : Down))

Brilliant, it worked first time!

Thanks,
Tim


Sim

unread,
Jun 10, 2004, 12:47:30 PM6/10/04
to
This works great, how can I split the result with a blank space.

For example I would like the ping to appear by servers in different area or
sites.

Thanks


"Tim Baker" <tim.bak...@NOSPAMsomersetcare.co.uk> wrote in message
news:10cdrpc...@corp.supernews.com...

Tim Baker

unread,
Jun 11, 2004, 4:15:06 AM6/11/04
to

"Sim" <simb...@btconnect.com> wrote in message
news:2irhl3F...@uni-berlin.de...

> This works great, how can I split the result with a blank space.
>
> For example I would like the ping to appear by servers in different area
or
> sites.
>
> Thanks
>

A quick & dirty solution would be to put a line containing "127.0.0.1," as a
separator in your text file. This would result in a line simply containing
": UP".

eg:

---a.txt---
10.0.1.1,Remote Site 1
10.0.2.1,Remote Site 2
127.0.0.1,
10.0.0.23,Printer 1
10.0.0.24,Printer 2

--Result--
Remote Site 1 : UP
Remote Site 2 : UP
: UP
Printer 1 : UP
Printer 2 : UP


Sim

unread,
Jun 11, 2004, 4:55:54 AM6/11/04
to
I'm very new to this any places you can recommend for a good tutorial.

How about adding a bit of colour, green for up and red (flashing if
possible) for down

Thanks

"Tim Baker" <tim.bak...@NOSPAMsomersetcare.co.uk> wrote in message

news:10ciqgb...@corp.supernews.com...

0 new messages