home *** CD-ROM | disk | FTP | other *** search
- isalive.exe
-
- I needed to use ping in a batch file to determine if a particular host was
- 'up'. Unfortunately, the ping supplied with Novell's LAN Workplace didn't
- set a DOS errorlevel to use in a conditional in a batch file. I didn't find a
- suitable (free) utility, so I wrote one.
-
- Basically, it's a filter used on the output of ping that sets the DOS
- errorlevel to 0 (normal) if the pinged device is alive, or to 1 is the device
- is not alive. It simply looks for the string 'alive' in the output of ping.
-
-
- The relevent section of an autoexec.bat file:
-
- ping hostname | isalive
- if errorlevel 1 goto DEAD
- rem hostname is alive, put needed lines between here and goto END
-
- goto END
- :DEAD
- rem hostname is not responding, put needed lines between here and END
-
- :END
-
-
-
- The source code for 'isalive.c'
-
- /* isalive.c use with 'ping' to set DOS errorlevel to 1 if not alive
- 0 if alive
- Mark Gogins 2/28/93 Compuserve 70243,1412
- Please feel free to modify any and all of this as you wish, even sell
- it for big bucks if you can. This program is free, clear, and released
- to the public domain. The author assumes no responsibility for any
- damage or loss caused by the use of this program, however it
- comes down.
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <process.h>
- #include <stdlib.h>
-
- #define DEAD 1
- #define ALIVE 0
-
- void main()
- {
- char temp[128];
- gets(temp);
- if ( strstr(temp,"alive"))
- {
- printf(temp);
- _exit(ALIVE);
- }
- else
- {
- printf(temp);
- _exit(DEAD);
- }
- }
-
-