Hi guys,
I've re-written my fax-to-multipage-postscript-email conversion script to
use the NOTIFY features in the 'fax' script. In doing so, I found some
problems with the NOTIFY feature itself -- it doesn't work if I use the "fax
receive" command, but only with "fax answer", and even then, only the _next_
time I run "fax answer" after receiving a fax!
This is pretty weird. Below, I'm including a patch for the fax script that
makes it run NOTIFY even for fax receive, so it will work in my setup (where
I can't use fax answer... long story).
I also include my new and improved efax.convert script, which takes $REMID
$FILES on the command line.
Have fun,
Avery
--- /usr/bin/fax.old Fri May 1 20:34:30 1998
+++ /usr/bin/fax Sun Nov 1 15:42:44 1998
@@ -494,7 +494,7 @@
case $OWNER in '') ;; *) chown $OWNER /dev/$DEV ;; esac
case $MODE in '') ;; *) chmod $MODE /dev/$DEV ;; esac
- for f in ${DEVN}.[0-9]* # clean up old log files
+ for f in ${DEVN}.[0-9]* *.log # clean up old log files
do
grep "done, returning $NOLOG" $f >/dev/null 2>/dev/null
case $? in
@@ -862,7 +862,22 @@
ERR=$?
case $ERR in
- 0) $RM $logfile ; break ;;
+ 0) #AVE $RM $logfile ; break ;;
+ f=$logfile
+ FILES=`sed -n -e '/received ->/s/^.*-> \(.*\)$/\1/p' $f`
+ FILES=`echo $FILES`
+ REMID=`sed -n -e '/remote ID ->/s/^.*-> \(.*\)$/\1/p' \
+ -etok -eb -e:ok -eq $f`
+ case $REMID in '') REMID='?' ;; esac
+ eval $NOTIFY
+ # The following two lines changed for Debian's efax after
+ # consultation with Ed Casas --edd 19 Oct 96
+ # echo >>${DEVN}.log
+ # cat $f >>${DEVN}.log
+ echo >>${FAXLOGDIR}/${DEVN}.log
+ cat $f >>${FAXLOGDIR}/${DEVN}.log
+ $RM $f
+ ;;
1) echo Busy... ;;
*) echo "There were errors (see ${logfile})." ; break ;;
esac
----------------------->>> efax.convert starts here >>>-----------------
#!/bin/bash
#
# fax conversion script for the efax package:
# called by /usr/bin/fax when a fax is received. Convert it to a
# multipage compressed postscript document and e-mail it to $MAILTO
# (default is postmaster)
#
# Copyright 1998 by Avery Pennarun <apenwarr@worldvisions.ca>
# Use, modify, and redistribute freely.
#
MAILTO="postmaster"
MAILER=/usr/sbin/sendmail
VERB=ewir
SPKR=-iM1
# override all options from the efax config file
source /etc/efax.rc
# process the command line
REMID="$(echo "$1" | sed 's/\(^\| \) */\1/g')"
shift
FILES="$*"
#set -x
xmit()
{
SUBJECT="$1"
(
cat <<-EOF
From: <efax@$HOSTNAME>
Mime-Version: 1.0
Subject: $SUBJECT
Content-Type: multipart/mixed; boundary="-"
This is a MIME encoded message. Use a MIME-compatible e-mail
package if you want to read it.
EOF
cat <<-EOF
---
Content-Type: application/postscript; name="fax.ps.gz"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="$(basename fax.ps.gz)"
EOF
shift
cat | gzip -c | mimencode
) | $MAILER $MAILTO
}
set -e
cd /var/spool/fax
PAGES="$(echo $FILES | wc -w | sed 's/[ ]*//g')"
echo "Processing fax from $REMID ($PAGES pages)"
efix -ops $FILES </dev/null 2>/dev/null \
| xmit "Fax: $PAGES pages from "\""$REMID"\"
mkdir done 2>/dev/null || true
mv $FILES done/ 2>/dev/null || true