Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delayed ping batch file??

Status
Not open for further replies.

Pharquah

MIS
May 14, 2001
27
0
0
GB
Right, I'm pretty poor at this batch file malarky, so can anyone help?
I need a batch file that will send a ping out once every 30 seconds. I got a kinda crappy way of doing it with a load of pings to 127.0.0.1 followed by a ping to the address I want to ping in a goto loop. But it just looks so amateurish, there has to be a better way to do it.
Any ideas???

Thanks.
 
sleep x with x being the number of seconds to wait. Marc Creviere
 
Okay, this is what I've tried:


:label
ping ipaddress -n 2
sleep 5
goto label


What's wrong? It won't work under NT, 2K or 95?

Thanks
 
Looks good to me, what's not working about it? Marc Creviere
 
I'm getting the 'sleep' is not recognised as an internal or external command, operable program or batch file message.

Arghhh!

Thanks for the pointer

Dave Lowton
 
I apologize, that is a Win2k command. I'll return to the drawing board. Marc Creviere
 
Again, I apologize, that is a Win2k Resource Kit command. I believe it is included in several other resource kits as well. Marc Creviere
 
Thanks Yizhar, that seems to have done the trick quite nicely, and thanks Filthpig, Nice try. I'd still like to know if it can be done with a batch file though... ;)

Dave
 
Pharquah, it can be done with a batch file, you just have to have a resource kit installed. Or at least sleep.exe installed. If you've got TechNet, you've got it. Marc Creviere
 
Yep, but this is something that I'm going to have roll out to lots of users, on multiple Microsoft OS's, so I don't want all of them installing the resource kit...I mean they're lusers, but one of them might find something...useful... Know what I mean..?

Dave
 
You could do something like....

if not exist c:\sleep.exe copy \\servername\sharename c:
:label
ping ipaddress -n 2
sleep 5
goto label


OR

:label
ping ipaddress -n 2
\\servername\sharename\sleep 5
goto label

 
Do this:
@echo off
:start
ping x.x.x.x
echo Testing a delay, starting at ...
echo.| time | find /v "new"
choice /c:. /t:.,60 /n Pausing for sixty seconds
echo ending at ...
echo.| time | find /v "new"
goto start

This has a little extra stuff in there for logging times,
but I am sure you can take it from here.
 
Cool Turbodog

Nice work.

If one expands the t:.,60 to 300 and note that looking in a ping output for 'unknown' will return an errorlevel 0 if found and 1 if not found, we can answer that quesiton of how to check a server every 5 minutes.

and if it is down send or net send or something.


Does that work?

j
 
If you are wanting to check the status of servers or ip addresses then send messages there is software that does a good job and is not too expensive. Take a look at What's Up Gold.
Terrel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top