#!/bin/sh

#. /usr/local/bcnu/etc/bcnuenv
. $BCNUHOME/agent/agent_head

HOSTFILE="/etc/hosts"
DEFSERVICES="bcnu    http    ftp     smtp    telnet"

echo "# discover on $STAMP" >$BCNUHOME/etc/discover

sed -ne '/^[^#]/p' $HOSTFILE |
{
while read ip host rest
do

OK=1

if $PING $host $PINGPAR >$BCNUTMP/$host.$$ 2>&1
   then
	DISCHOST=$host
	for param in $DEFSERVICES
	do
		bcnu_param
		SERVICE=$p1
		FILE=${p2:+"-f $p1"}

		if $BCNU -a net -s $SERVICE $FILE $host >$BCNUTMP/$host.$SERVICE 2>&1
		then
			DISCHOST="$DISCHOST\t$param"
		fi

	done
	echo $DISCHOST >>$BCNUHOME/etc/discover
	echo $DISCHOST
fi	
done
}
