Cover V02, I02
Article
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Listing 1
Listing 10
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7
Listing 8
Listing 9

mar93.tar


Listing 3: The getlbl command

1: #
2: # getlbl:
3: #   Prompt for label printer name, with default
4: #   Written by Leor Zolman, 9/91
5: #
6: # Usage:
7: #   getlbl
8: #   Returns the appropriate lp options on standard output.
9: #
10: # Background:
11: #   There are only two label printers present in this installation,
12: #   one in the Marketing Dept. (mktg) and one in Internal Services (is).
13: #   So, by default, anyone in the mktg (or per) departments get the mktg
14: #   label printer, and everyone else gets the is label printer.
15:
16: PTRDIR=/u/leor/docs/Cols/SA/Printers            # Printer control directory
17: CODECHAR=B
18: WHAT="Label-Printer"
19:
20: [ $# -gt 1 ] && echo "Usage: $0 [default-$WHAT]" >&2 && exit
21:
22: . $PTRDIR/initmap.sh        # initialize and handle special-case mappings
23:
24: defarea=`sed -n 's/^'$DEPT',.*\([A-Z]\)$/\1/p' dept.map`
25: [ $DEBUG = Y ] && echo "defarea = $defarea"
26:
27: #
28: # choose printer region:
29: #
30:
31: while true
32: do
33:     echo "\n   Label Printer Areas:" >&2
34:     sed -n 's/^.*"\(.\)\(.*\)".*$/\1\2  (\1)/p' dept.map
35:     while true
36:     do
37:         echo "\nSelect an area (by single-letter code) [$defarea]: \c">&2
38:         read area
39:         [ "$area" = "" ] && area=$defarea
40:         area=`echo "$area\c" | tr '[a-z]' '[A-Z]'`
41:         if tmp=`grep $area'$' dept.map`
42:         then
43:             DEPT=`echo $tmp | cut -d, -f2 | tr -d " "`
44:             break
45:         fi
46:     done
47:     [ $DEBUG = Y ] && echo "after dept loop, DEPT = $DEPT"
48:     . $PTRDIR/initmap.sh l          # force label paper type
49:     break
50: done
51:
52: . $PTRDIR/proxmap.sh
53: echo $lpopts
54:
55: exit 0