We had at one point a bit of discussion about scripts, and I have
another I would like to contribute. To make room for a future
baby, I had to relinquish my printer to my wife's computer area.
So I created a script that would automate my print-to-disk
activity.
I think it might have some interest because it also demo's how to
use "getopt" to parse command-line options in a script.
---------- For your enjoyment ---------
#!/bin/bash
# A print-to-file script; also works as a pipe.
# Replace this variable with the program that filters your print output
FILTER="/etc/magicfilter/ljet4-filter"
# ----- Script starts here
OPT=`getopt "ho:" $*` || exit
eval set -- "$OPT"
while test "X$1" != "X--"; do
case "$1" in
-h)
echo "Usage: lp2f [infile ...] [-o outfile]"
exit
;;
-o)
shift
OUTFILE=$1
;;
esac
shift
done
shift
if [ "$*" == "" ]; then
set -- -
fi
if [ $OUTFILE ]; then
echo -n "" > $OUTFILE
for i in $*; do
cat "$i" | $FILTER >> $OUTFILE
done
else
for i in $*; do
cat "$i" | $FILTER
done
fi
--
Don Bindner <[EMAIL PROTECTED]>