Discussion Locked

ping error evel return

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello Help required

Is there a ping.com version that returns a different errorlevel when it replys to when it times out eg.
ping Known_good_machine
echo %errorlevel%
=0
ping Known_bad_machine
echo %errorlevel%
=1

In my version they both return a 0

Im trying to create a .bat file that pings our four servers and creates a file according to their response
ie.
reply
md c:\server1OK.dir
time out
md c:\server1DEAD.dir

Can anyone help ?????????????

3 replies

by pvp

There might be, but anytime I've had to do this, the output of ping was redirected to a file or piped to grep, and if "Request timed out" was found, it had failed.

You're going to have to do a bit of "translation" to your own OS, but that's the gist of it.

by chris r

thanks for looking and responding but the points have gone esle where, ill send you the .com required.
You just whack it in system32 and use it instead of ping and then ...
reply = errorlevel 0
time out = errorlevel 1
hoorah !!!!!
eg.
alive server_name
echo err= %errorlevel%
IF %ERRORLEVEL% ==1 goto :no
IF %ERRORLEVEL% ==0 goto :yes

etc. etc.

by chris r

sorry pvp ive just sussed out I cant send it without your address, duh !
If u want it give me your
mailto:

thanks again

This discussion is closed to new replies.