Re: script to ping a server

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Austin M. Horst (anonymous_at_discussions.microsoft.com)
Date: 03/07/04


Date: Sun, 7 Mar 2004 13:11:08 -0800

If you don't care what type of script, a batch script would be very simple.

PING 127.0.0.1 | FIND/I "TTL=" > NUL
IF %ERRORLEVEL% == 1 enter command(s) to execute if ping failed
IF %ERRORLEVEL% == 0 enter command(s) to execute if ping was successful

or

PING xyz.com | FIND/I "BYTES=" > NUL
IF %ERRORLEVEL% == 1 enter command(s) to execute if ping failed
IF %ERRORLEVEL% == 0 enter command(s) to execute if ping was successful

Austin M. Horst



Relevant Pages

  • Re: ERRORLEVEL IN WINDOWS CE 5.0
    ... ERRORLEVEL variable doesn't seem to change to any other value other than 0. ... When I open the command shell on the ... "Cannot execute aaaaa.exe" ... \>IF NOT ERRORLEVEL 0 ECHO HELLO ...
    (microsoft.public.windowsce.embedded)
  • Re: Getting the return value of a command line program
    ... We were doing scripting in awk, ... we could get the return status of an executed program ... was to execute a batch file, ... the last line of output (the echoed errorlevel). ...
    (comp.lang.tcl)
  • Re: Log output of regsvr32 command.
    ... statements in my batch file and when this piece of code used to ... execute, it would always returns true even if dll registration fails. ... *** %ErrorLevel%, which was introduced with WinNT or ...
    (microsoft.public.windowsxp.general)
  • Re: DOS question: multiple commands on one line
    ... if ERRORLEVEL 4 echo errorlevel = 4 ... && Execute the following command only if ErrorLevel=0 ...
    (microsoft.public.win2000.general)
  • Re: Easily switching between 2 color schemes
    ... You could try saving a batch script that automates the process, ... then assign a key combination to execute it. ...
    (sci.med.vision)