#	Sample despool from directory hierarchy
#	This example assumes that during the day reports
#	are created for a set of destinations, and that
#	generally more than one report is created per destination.
#	This script is run a night, and generates a single
#	faxsend command for each destination to send all of the
#	reports for that destination.
#
#	We assume that under the OUTGOING directory are a bunch
#	of subdirectories whose names are the "nicknames" of
#	the destinations.  In each subdirectory are the reports
#	to be sent.
#
OUTGOING=/usr/spool/reports
cd $OUTGOING
for DIR in *
do
	if [ -d $DIR ]			# For each subdirectory
	then
		NICKNAME=$DIR
		faxsend $NICKNAME $DIR/* >/dev/null 2>&1
		if [ $? = 0 ]
		then
			rm -rf $DIR	# Delete the reports
		else
			echo "Couldn't find $NICKNAME in faxphone"
		fi
	fi
done
