Computing.Net > Forums > Programming > batch files , ping results

batch files , ping results

Reply to Message Icon

Original Message
Name: haresh7263
Date: October 15, 2006 at 17:36:08 Pacific
Subject: batch files , ping results
OS: xp
CPU/Ram: p4 1gb
Model/Manufacturer: ibm
Comment:

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


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: October 15, 2006 at 23:11:12 Pacific
Subject: batch files , ping results
Reply: (edit)

In my version of ping there are three main messages:

Unknown host
Reply from
Request timed out

What exact messages do you get?



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: Guy
Date: October 16, 2006 at 19:09:03 Pacific
Subject: batch files , ping results
Reply: (edit)

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



Report Offensive Follow Up For Removal

Response Number 3
Name: haresh7263
Date: October 17, 2006 at 19:58:07 Pacific
Subject: batch files , ping results
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: October 19, 2006 at 05:12:58 Pacific
Subject: batch files , ping results
Reply: (edit)

@echo off

ping somesite2a2.com > %TEMP%\pinglog

find "Unknown host" < %TEMP%\pinglog > nul
if not errorlevel 1 echo custom msg1 && goto :eof

find "Reply from" < %TEMP%\pinglog > nul
if not errorlevel 1 echo custom msg2 && goto :eof

find "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



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: batch files , ping results

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge