[GLLUG] (OT) Win32 ping and errorlevel ?

Melson, Paul PMelson@sequoianet.com
Fri, 1 Feb 2002 16:21:56 -0500


This is a multi-part message in MIME format.

------=_NextPartTM-000-d115678f-eafe-4212-bebe-3d3f8acbcd45
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C1AB66.7A1C4988"

------_=_NextPart_001_01C1AB66.7A1C4988
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Sorry for the Microsoftish question, but it seems like someone might =
have stumbled across this issue already.

Does anybody know about PING.EXE for WinNT/2K and its errorlevels?  I'm =
trying to script a Scheduled Task that would check to see if a network =
connection (VPN in this case, but that's irrelevant) is up before =
launching MOBSYNC.EXE.  Here is the offending code:

@echo off
ping -n 5 10.0.0.8				# This sends 5 packets to overcome any ARP or lag =
issues.
ping -n 1 -w 5000 10.0.0.8			# This sends 1 packet w/ 5sec wait time to =
assure the IP is up.
if not errorlevel 0 goto Fail			# If there is any errorlevel other than =
0, we have a problem.


But we have a problem, anyway.  It seems to be skipping the "if" =
statement.  Regardless of whether or not it's able to ping the host, it =
tries to run the commands to connect to the host and sync up.  Is there =
something wrong w/ my syntax?  I chose to do it this way because I was =
unable to find any documentation on PING.EXE and specific errorlevels.  =
Or does PING.EXE simply not return errorlevels?  I would do this w/ a =
shell script in Cygwin, but Cygwin uses the same ping program, and it =
seems like such a simple task to use Ping.pm for.  Any help you can =
provide is greatly appreciated.

PS - the actual batch file doesn't have the #-marked comments.

Thanks,
PaulM

------_=_NextPart_001_01C1AB66.7A1C4988
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.0.5762.3">
<TITLE>(OT) Win32 ping and errorlevel ?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=3D2 FACE=3D"Arial">Sorry for the Microsoftish question, =
but it seems like someone might have stumbled across this issue =
already.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Does anybody know about PING.EXE for =
WinNT/2K and its errorlevels?&nbsp; I'm trying to script a Scheduled =
Task that would check to see if a network connection (VPN in this case, =
but that's irrelevant) is up before launching MOBSYNC.EXE.&nbsp; Here is =
the offending code:</FONT></P>

<P><FONT SIZE=3D2 FACE=3D"Arial">@echo off</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">ping -n 5 =
10.0.0.8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # This sends 5 packets to =
overcome any ARP or lag issues.</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">ping -n 1 -w 5000 =
10.0.0.8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # This sends 1 packet w/ 5sec =
wait time to assure the IP is up.</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">if not errorlevel 0 goto =
Fail&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # If there is any errorlevel =
other than 0, we have a problem.</FONT>
</P>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">But we have a problem, anyway.&nbsp; It =
seems to be skipping the &quot;if&quot; statement.&nbsp; Regardless of =
whether or not it's able to ping the host, it tries to run the commands =
to connect to the host and sync up.&nbsp; Is there something wrong w/ my =
syntax?&nbsp; I chose to do it this way because I was unable to find any =
documentation on PING.EXE and specific errorlevels.&nbsp; Or does =
PING.EXE simply not return errorlevels?&nbsp; I would do this w/ a shell =
script in Cygwin, but Cygwin uses the same ping program, and it seems =
like such a simple task to use Ping.pm for.&nbsp; Any help you can =
provide is greatly appreciated.</FONT></P>

<P><FONT SIZE=3D2 FACE=3D"Arial">PS - the actual batch file doesn't have =
the #-marked comments.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Thanks,</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">PaulM</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C1AB66.7A1C4988--

------=_NextPartTM-000-d115678f-eafe-4212-bebe-3d3f8acbcd45--