A script to retain a copy of outgoing faxes

Dec 10, '08 07:30:00AM

Contributed by: xr4ti

For the few times I need to send a fax, I'm not going to mess with getting one of my broken third-party fax applications to run again. But the built-in OS X fax capability has some annoying limitations. One of the more annoying ones is that it doesn't save a copy of outgoing faxes. I wrote the following script as a kluge, to grab a copy of outgoing faxes and store them in /Users/Shared/Faxes/Outbox. The fax is saved (complete with the cover page) as a multi-page TIFF file.

!/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_log
I saved the script as watch_fax, in a spot where my admin user could get to it. You have to sudo to run this script, because it has to copy from /private/var. Don't forget to make it executable with chmod u+rx watch_fax.

To 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.]

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20081205225217399