#!/bin/csh -f

# Fax a dvi file to a list of people, including an appropriate cover
# page for each.  First argument is a file containing a list of names
# and fax numbers; second argument is the dvi file; third argument is
# the number of pages in the dvi file; additional arguments are sendfax
# options.

set tempfile = faxlist.$$.tex

if ($#argv < 3) then
  echo "Usage: faxlist destfile dvifile pages [sendfax-options]"
  exit(1)
endif

if (! -r $2)  then
  echo "faxlist: Can't open $2"
  exit 4
endif

cat ~/tex/templates/umdeefax.tex > $tempfile

subst "%\\pageadjust{0}%\\pageadjust{$3}%" $tempfile

echo '' | latex $tempfile >/dev/null

cat $1 | flinternal $tempfile $2 $argv[4-]

rm -f $tempfile:r.*
