#!/bin/csh -f
##  see if a given computer is dead or not, if alive, 0 else 1 is
##  returned as a return code.
##  usage:  seeifdead  machine
##  the user can check $status.  if 0, machine is alive
##                               if 1, machine is dead.
##   see if machine is dead or unknown
#set x=`/usr/etc/ping $1 64 2 | grep "100% packet loss\|unknown host"`
if( $#argv != 1) then
    echo "Usage: seeifdead hostname"
    exit 1
endif
rm -f errorlog


myping "-s $1 64 2" >&  errorlog

set x=`grep "100%" errorlog | grep "loss"`
if( $#x  ) then
#       echo "dead"
       exit 1
else
       set x = `grep "unknown host" errorlog`	
       if( $#x ) then
#		echo "not exist"
		exit 1
       else	
#             echo "alive"
             exit 0
       endif	
endif

