#!/bin/bash
# written 2000-06-10 by Frank Heyder (heyder@heydernet.de)
# isalive host [timeout]
if [ $# -eq 0 ]; then
	echo usage: $0 host [timeout] 1>&2
	exit 2
fi
if [ $# -gt 2 ]; then
	echo usage: $0 host [timeout] 1>&2
	exit 2
fi
REMOTEHOST=$1
if [ $# -eq 2 ]; then
	TIMEOUT=$3
else
	TIMEOUT=3
fi
ping -c 1 $REMOTEHOST &>/dev/null &
PINGID=$!
sleep $TIMEOUT
kill $PINGID &>/dev/null
if [ $? -eq 0 ]; then
	exit 1
else
	exit 0
fi
