Listing 1: The llp command
1: #
2: # llp:
3: # replacement for "lp" command, providing proximity-driven
4: # intelligent departmental printer job routing.
5: #
6: # Written by Leor Zolman, 9/91
7: #
8: # Usage:
9: # llp [-formtype] ...
10: # invokes "lp", translating formtype into appropriate "-d" clause.
11: #
12: # If $SOFTCOPY is set to Y in the current environment, and the file
13: # $SOFTDIR/Soft.status consists of "B" or "F", then output is written to
14: # a file whose name is specified by the contents of $SOFTDIR/Softfile.
15: # If $SOFTDIR/Soft.status is "B", then output is also sent to "lp".
16: #
17:
18: PTRDIR=/u/leor/docs/Cols/SA/Printers # Printer control directory
19: CODECHAR=L # for restricting selections
20: WHAT="Paper"
21:
22: SOFTDIR=$HOME/.Soft # user's Soft-copy config dir
23: SOFTSTAT=$SOFTDIR/Soft.status # file containing soft-copy status
24: SOFTFILE=$SOFTDIR/Soft.file # file containing name of the file
25: # to append soft-copy output to
26: #
27: # Process command line, handle intializations and special-case mappings:
28: #
29:
30: . $PTRDIR/initmap.sh
31:
32: #
33: # Map $ptype and $DEPT into appropriate lp text in $lpopts:
34: #
35:
36: . $PTRDIR/proxmap.sh
37:
38: [ $DEBUG = Y ] && exit
39:
40: #
41: # Support "Soft-copy" feature, to allow Sys Admin's to generate file output
42: # in place of printed output for testing and saving paper.
43: #
44:
45: if [ "$SOFTCOPY" = Y ]; then
46: read SOFTCODE < $SOFTSTAT
47: read SOFTNAME < $SOFTFILE
48: case "$SOFTCODE" in
49: B) if [ $# -eq 0 ]; then
50: exec tee -a $SOFTNAME | lp $lpopts
51: else
52: exec cat $* | tee -a $SOFTNAME | lp $lpopts
53: fi;;
54: F) exec cat $* >> $SOFTNAME;;
55: esac
56: fi
57:
58: #
59: # If Soft copy is disabled, just go to printer:
60: #
61:
62: if [ $# -eq 0 ]; then
63: exec lp $lpopts -
64: else
65: exec lp $lpopts $*
66: fi
|