Cover V04, I05
Article
Figure 1
Figure 2
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Sidebar 1
Sidebar 2

sep95.tar


Listing 3: Rerouting print jobs

#!/bin/sh
# Script to reroute print jobs that were printed to the printers "lp" or "lw".
# This script will search the user's .login file for the "setenv PRINTER"
# statement.  It will then use that printer definition to reroute the print
# job to that printer.

BINDIR=/usr/local/bin
PATH=$BINDIR:/bin:/usr/bin:/usr/ucb:/usr/local/lib/ts
export PATH

while test $# != 0
do      case "$1" in
-n)     user=$2 ; shift ;;
-n*)    user=`expr $1 : '-.\(.*\)'` ;;
-h)     host=$2 ; shift ;;
-h*)    host=`expr $1 : '-.\(.*\)'` ;;
-*)     ;;
*)      afile=$1 ;;
esac
shift
done

uhome=`ypcat passwd | grep "^$user:" | cut -d":" -f6`
cd $uhome
pname=
pname=`grep "^setenv PRINTER" .login | cut -d" " -f3`
if [ -z "$pname" ]; then
echo "PRINTER variable not defined in .login file for $user" |
/usr/ucb/mail -s "Print job failed" $user,print_manager
exit
fi
if [ "$pname" = "lw" ]; then
cat /usr/local/lib/ts/lw_msg | /usr/ucb/mail -s "Print job failed"
$user,print_manager
exit
fi
cat - | lpr -P"$pname"
exit