!/bin/zsh
if [ $EUID -ne 0 ]; then
echo YOU MUST SUDO TO ROOT TO RUN THIS
exit
fi
dt=`date '+%Y%m%d-%H%M%S'`
t=''
echo Waiting for efax to run.
while [ x$t = x'' ]; do
t=`ps -ef|grep efax|grep -v grep`
sleep 1
done
ls -al /var/spool/cups/tmp
f=`echo $t|sed -e 's#.*\(/private.*\)#\1#'`
if [ -r $f ]; then
echo COPYING $f to /Users/Shared/Faxes/Outbox/$dt.tiff
cp $f /Users/Shared/Faxes/Outbox/$dt.tiff
sudo chmod a+r /Users/Shared/Faxes/Outbox/$dt.tiff
open /Users/Shared/Faxes/Outbox
else
echo file $f doesn\'t exist
exit
fi
echo If something goes wrong, try \"faxlog debug\"
tail -f /var/log/cups/error_logTo run it, I type sudo watch_fax. This script ends with a tail -f, which will show you the fax log as it's being written. When you're done watching the fax log, you'll have to kill the tail with Control-C. This script also references another of my scripts, called faxlog, that helps you set debug mode for the fax log. You can find that script in this hint.
[robg adds: I haven't tested this one.]

