Cynosure.X International LLC

: :

Add Comment | Related Links | TrackBack
Related Content

IsHostAlive.sh (GPL)

IsHostAlive.sh is a Bourne Shell script that helps you determine whether a network host is on and responding to network pings. This script will return 1 or 0, which represents true and false respectively. This script returns true when the host responds.

Because this script uses the ping command to determine whether a host is on, it usually returns a result immediately when the host responds. However, if the host is off, it could take up to a second before this script times out and return 'false'.

IsHostAlive.sh is distributed as executable source code under the GNU General Public License. Please see the license agreement elsewhere on this site.

Usage

IsHostAlive.sh host

Examples

$ IsHostAlive.sh www.google.com
1

$ IsHostAlive.sh 192.168.1.22
0

Attached File: IsHostAlive.sh (404 B)

Chieh Cheng
Mon, 29 Dec 2008 21:14:11 +0000

The IsHostAlive.sh script was originally written on Mac OS X's Darwin UNIX shell. It uses the ping utility. However, the output of the ping utility on Darwin differs slightly from the Ubuntu Linux distribution. Therefore, I have modified the script slightly so that it would work on most flavors of UNIX and Linux operating systems. The newer version is attached below.

Attached File: 1 - IsHostAlive.sh (400 B)

Chieh Cheng
Fri, 02 Jan 2009 07:23:52 +0000

It seems that the previous version of "IsHostAlive.sh" were looking for an unreliable regular expression, causing it to report that dead hosts are alive. I have fixed the bug in the version attached below.

Attached File: 2 - IsHostAlive.sh (401 B)

Chieh Cheng
Wed, 25 Mar 2009 01:45:29 +0000

I found more differences between Darwin and Linux. The timeout flag for ping are different on the two different platforms. So I have made changes to support both platforms. The new version is attached below.

Attached File: 3 - IsHostAlive.sh (622 B)

Chieh Cheng
Wed, 22 Apr 2009 18:15:34 +0000

Darwin on Mountain Lion is once again slightly different than its predecessor, causing "IsHostAlive.sh" to fail. I've updated "IsHostAlive.sh" with the difference, so that it should work on all Darwin and Linux alike. The new version is attached below.

Attached File: 4 - IsHostAlive.sh (1 KB)

Chieh Cheng
Wed, 17 Apr 2013 11:41:24 +0400

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

TrackBack

TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

Title: Ubuntu 14.04 LTS - Wireless Network Stops Working Periodically
Weblog: GearHack
Excerpt: I found the work-around. It doesn't solve the problem, but keeps the server online. Basically, I create a root cron script that checks network connection every five minutes. When the network connection fails, it restarts the network. Here is the basic code: result=`IsHostAlive.sh "${router}" . . .
Tracked: Wed, 09 Jul 2014 22:44:50 +0400

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 10 + 8?
Click button only once, please!

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

56 Users Online

Hacking Digital Cameras
Fun for Photographers



Amazon Associate

Copyright © 1996 - 2024. All Rights Reserved.