#!/bin/sh
. config/paths.sh
DEBUG=""
if [ -z "$1" ]; then 
  $ECHO "Usage fwping [-v] [-f filename] [ systems]"
exit
fi
FW_TIMEOUT=2
STD_PORTS="25 53 80 139 143 4000"
if [ "$1" = "-f" ]; then
  TARGETS="`cat $2`"
  set *="  " `$ECHO $TARGETS`
  shift
elif [ "$1" = "-v" ]; then
  DEBUG="ON"
  shift
else
  set *=" " $*
  shift
fi
while [ "$1" ]; do
# For all IP's requested, do a tcp_scan on the STD_PORTS
  TMP=`$TCP_SCAN -a -f $FW_TIMEOUT $1 $STD_PORTS | $GREP -iv timed |\
     $GREP -iv "no route" | $GREP -iv "unreachable"`
  if [ "$TMP" ]; then
    if [ "$DEBUG" ]; then $ECHO $TMP;fi
    $ECHO "$1 is alive"
  fi 
shift
done
exit 0
