Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Batch file, ping results
I want to run something similar at command prompt and display a custom message
ping www.ebay.com.at
if ping results == "could not found host"
ECHO "My custom processing and message"
else if ping results == "request time out"
ECHO "My custom processing and message"
else ECHO "My custom processing and message"if some one could provide the code :)
haresh7263 AT hotmail.com
Knowledge is meant to to shared

In my version of ping there are three main messages:
Unknown host
Reply from
Request timed outWhat exact messages do you get?
=====================================
If at first you don't succeed, you're about average.M2

The "timeout" message does not mean a lot in general.
The host *could* be there, serving something at some particular port.
It could just be dropping the ping ICMP packets on the floor. I have set up systems like that.
Guy

Hello Mechanix2Go,
what i want is to differentiate (interprete) the ping results within the code. And depending on the ping results, execute the business logic.
Can you give me the exact syntax (code), how to interprete the ping results in code. Please refer to my psuedo code above.
Thanks in advance
Haresh
Knowledge is meant to to shared

@echo off
ping somesite2a2.com > %TEMP%\pinglog
find "Unknown host" < %TEMP%\pinglog > nul
if not errorlevel 1 echo custom msg1 && goto :eoffind "Reply from" < %TEMP%\pinglog > nul
if not errorlevel 1 echo custom msg2 && goto :eoffind "Request timed out" < %TEMP%\pinglog > nul
if not errorlevel 1 echo custom msg3 && goto :eof
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |