Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Simple Ping Script

Reply
Thread Tools Display Modes

Simple Ping Script

 
 
K
Guest
Posts: n/a

 
      11-17-2008
What are the errorlevels for the ping command?

I am trying to create a script that will ping a remote router, and in the
event it is non-responsive, will cause the machine the script is running on
to reboot without warnings or prompts.

Any help much appreciated.


 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      11-17-2008

"K" <> wrote in message
news:...
> What are the errorlevels for the ping command?
>
> I am trying to create a script that will ping a remote router, and in the
> event it is non-responsive, will cause the machine the script is running
> on to reboot without warnings or prompts.
>
> Any help much appreciated.


Ping does not have any specific error levels. You need to check its output
in order to work out if the remote computer is responding, e.g. like so:

ping SomePC | find /i "bytes=" > nul && echo SomePC is responding.
or maybe
ping SomePC | find /i "bytes=" > nul || echo SomePC is not responding.


 
Reply With Quote
 
K
Guest
Posts: n/a

 
      11-17-2008
>> What are the errorlevels for the ping command?
>>
>> I am trying to create a script that will ping a remote router, and in the
>> event it is non-responsive, will cause the machine the script is running
>> on to reboot without warnings or prompts.
>>
>> Any help much appreciated.

>
> Ping does not have any specific error levels. You need to check its output
> in order to work out if the remote computer is responding, e.g. like so:
>
> ping SomePC | find /i "bytes=" > nul && echo SomePC is responding.
> or maybe
> ping SomePC | find /i "bytes=" > nul || echo SomePC is not responding.


After some googling I have found mention of an errorlevel 1 for a fail and 0
for a result but they seem hit and miss. Certainly not something I am that
confident on trusting a reboot to.


 
Reply With Quote
 
J Ford
Guest
Posts: n/a

 
      11-17-2008
The problem I see with the script, isn't with doing the logic. BUT, if you
are not able to get a response from pinging, chances are you will not be able
to send a remote reboot either.

"K" wrote:

> What are the errorlevels for the ping command?
>
> I am trying to create a script that will ping a remote router, and in the
> event it is non-responsive, will cause the machine the script is running on
> to reboot without warnings or prompts.
>
> Any help much appreciated.
>
>
>

 
Reply With Quote
 
K
Guest
Posts: n/a

 
      11-18-2008
It;s a local reboot - various reasons why but if I cannot contact a remore
router I want to bounce the local machine.

> The problem I see with the script, isn't with doing the logic. BUT, if
> you
> are not able to get a response from pinging, chances are you will not be
> able
> to send a remote reboot either.
>
> "K" wrote:
>
>> What are the errorlevels for the ping command?
>>
>> I am trying to create a script that will ping a remote router, and in the
>> event it is non-responsive, will cause the machine the script is running
>> on
>> to reboot without warnings or prompts.
>>
>> Any help much appreciated.
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Ping Question Noah Windows Server 0 10-16-2008 08:08 PM
Simple script to ping an IP (test connectivity) TJCooper1972 Scripting 14 05-27-2008 09:08 PM
Recommend? a simple ping heartbeat utility? Server Networking 2 09-19-2004 02:34 PM
Simple script help Jeff Scripting 1 02-25-2004 05:28 PM
Best Way - Simple Log On Script AJ Whitten Scripting 1 11-04-2003 11:27 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59