#
#	dunning_letter	-	sample shell script to generate a
#				"pay your bill or else" form letter
#
#	Usual usage is to create a ".faxgroup" entry for, say,
#	a group call "deadbeats" with several nicknames in the group.
#	Then, to generate the FAX form letters: use a command like:
#
#	faxsend -F deadbeats '(dunning_letter)'
#
#	Notice the use of the '-F' option, and the special syntax to
#	specify that a program is to run (rather than a simple file).
#
#	NOTE: environment variable $tokey is automatically
#	set (by faxsend) to the nickname of the person to be reminded.
#	This key can be used to look up the name/address of the person
#	in the .faxphone database.  It could also be used as the key
#	into an auxilliary, user supplied, database of information.
#
TAB="	"	# a TAB character
#	Get the fields out of the .faxphone database
ofs="$IFS"
IFS="$TAB"
set `grep "^$tokey$TAB" $HOME/.faxphone |
	sed -e "s/$TAB$TAB/$TAB $TAB/g" -e "s/$TAB$TAB/$TAB $TAB/g"`
IFS="$ofs"
#	Rename the positional parms with symbolic names for readability
KEY="$1"; NAME="$2"; COMPANY="$3"
ADDR1="$4" ADDR2="$5" ADDR3="$6" ADDR4="$7" ADDR5="$8"
VOICE="$9"; shift; FAX="$9"; shift; EMAIL="$9"
DATE=`date`
#	Now, we'll just 'cat' out an ASCII form letter with the
#	appropriate substitions.  You can also get fancy and use
#	faxjet or faxmerge et al to create a FAX output file.
cat <<EOF

	Ruthless Bill Collectors, Inc.
	123 Dunning Street
	Anytown, USA
	

	$NAME
	$ADDR1
	$ADDR2
	$ADDR3
	$ADDR4
	$ADDR5

	$DATE

	Dear $NAME:

	You haven't paid your bill in a long time.  We have your
	name on our list of poor credit risks.  If you don't pay
	us soon, we'll have Guido the Enforcer call you on your
	telephone [ $VOICE ] to arrange to break your legs.

	Sincerely,


	Vito
EOF
