#!/bin/csh -f

set tempfile = /tmp/faxrecord.mail.$USER.$$

set pages = `txt2dvi $1 | sed -n 's+.*\.dvi (\([0-9]*\) page.*+\1+p'`
echo $1:r | tr '_' ' ' > $tempfile

faxlist $tempfile $1:r.dvi $pages $argv[2-]
# For testing, replace with:
# cat $tempfile; echo $tempfile $1:r.dvi $pages $argv[2-]

if (! $status) rm -f . $1:r.{log,dvi}

rm -f $tempfile
