#!/bin/sh
#	program:	subdom
#	release:	1.5.0
#	purpose:	Print a list of sub-domains in this domain.  This
#			is not recursive unless the "-r" command-line flag
#			is given.  This is the top-most shell script for
#			the program.  We basically call the recursive main
#			part (subdom2) and return whatever error status he does.
#	input:		Domain name on command line,
#			optional nameserver to direct queries to.
#	output:		A list of subdomains within the given domain,
#			or the word "ERROR" (distinguishable from a real
#			record because it has no period on the end).
#	exit value:	0 if succeeds, 1 if fails (and "ERROR" output).
#
# Copyright (C) 1993-2000 Paul A. Balyoz <pab@domtools.com>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

TMP=/tmp/subdom0.$$

/usr/local/domtools/bin/subdom2 $* > $TMP
status=$?
if test $status -ne 0; then
	rm -f $TMP
	exit $status
fi

uniq < $TMP
status=$?
if test $status -ne 0; then
	rm -f $TMP
	exit $status
fi

rm -f $TMP
exit 0
