"UNIX" can mean a lot of things.
Ok, here's what you can do, replace lpr with a script.
First, find out where it lives. Let's say for example it's /usr/bin/lpr.
Then replace with a script that logs how it's called and tries to copy the printer output to a file.
Code:
$ su
Password:
# mv /usr/bin/lpr /usr/bin/real.lpr
cat > /usr/bin/lpr
#!/bin/sh
exec >/tmp/lpr.debug 2>&1
set +xv
echo "Lpr called on `date` with these arguments:"
echo "0:$0 1:$1 2:$2 3:$3 4:$4 5:$5 6:$6 7:$7 8:$8 9:$9"
filenames=""
args=""
while [ $# -gt 0 ]; do
case $1 in
-* ) args="$args $1" ;;
* ) filenames="$filenames $1" ;;
esac
shift
done
if [ "$filenames" = "" ]; then
filenames=/tmp/lpr.stdin
cat > /tmp/lpr.stdin
fi
cat /dev/null > /tmp/lpr.output
for f in $filenames; do
cat $f >> /tmp/lpr.output
done
exec /usr/bin/real.lpr $* < /tmp/lpr.output
exit 0
^D
# chmod 755 /usr/bin/lpr
That should get you started. Check /tmp/lpr.debug to see what's happening.