#!BOURNESHELL
#	program:	basedomain
#	input:		one domain name on the command line.
#	output:		the domain below this one (this is a subdomain of it)
#			is sent to stdout, or "ERROR" if a problem occurs.
#			Trying to get the basedomain of "." is handled as
#			an error.
#			Usage printed to stderr, too, if usage error occurs.
#	example:	"cse.nau.edu." -> "nau.edu."
#	exit value:	0 if nothing goes wrong, 1 if something did.

AWK=DOMLIB/basedomain.awk

if test $# -ne 1; then
	echo "usage: $0 dom.ain." >&2
	echo 'ERROR'
	exit 1
fi

echo $1 | awk -f $AWK
status=$?
if test $status -ne 0; then
	echo 'ERROR'
	exit 1
fi

exit $status
