#!/bin/sh #@(#)lpr look-alike for HP-UX Version 1.00 - 12/14/93 John S. Urban #set -x # # A horid little script came on our HP called /usr/bin/lpr # that purported to make lp look like lpr. Assuming you are # using the standard HP remote model (rmodel) script this will # come a lot closer to looking like a BSD lpr command than that # strange little procedure. By the way, I wouldn't give the # rmodel script any awards anyway. Look at the lp command that # comes out at the end of this script when you have used several # features such as -h and -w and -J and you will wonder why someone # didn't make the BSD garbage optional the first time he used his # own procedure (which raises questions in my mind as to whether # anyone did). # # lpr - send a job to the printer # # These filter options offer a standard user # interface, and all options may not be avail- # able for, nor applicable to, all printers. # # NOT IMPLEMENTED: # # -r Remove the file upon completion of spooling, # or upon completion of printing with the -s # option. # # -1 font # -2 font # -3 font # -4 font Mount the specified font on font position 1, # 2, 3 or 4. The daemon will construct a # .railmag file in the spool directory that # indicates the mount by referencing # /usr/lib/vfont/font. # ################################################################################ usage="Usage: lpr [ -Pprinter ] [ -#copies ] [ -Cclass ] [ -Jjob ] [ -Ttitle ] [ -i [ indent ] ] [ -1234font ] [ -wcols ] [ -r ] [ -m ] [ -h ] [ -s ] [ -filter-option ] [ filename ... ] WARNING: -r and -1234font are NOT implemented " # lpr reads from the standard input if no files are specified. trap 'echo lpr OUCH; exit 1' 2 ################################################################################ # # Supply initial defaults. # # PRINTER is the default for BSD lpr; LPDEST is the default for SysV lp PRINTER=${PRINTER:-$LPDEST} LINK="-c" COPIES="1" WIDE=132 HEADER="" FILES="" FILTER="" TITLE="" INDENT="" MAIL="" ################################################################################ # # Get selected parameters. # while [ -n "$1" ] do ################################################################################ # -Pprinter Send output to the named printer. Otherwise # send output to the printer named in the # PRINTER environment variable, or to the # default printer, lp. ################################################################################ case "$1" in -P) PRINTER="$2"; if [ "$PRINTER" = "" ]; then echo "lpr: Error: No PRINTER specified following -P." >&2 echo "$usage" >&2 exit 1 fi shift;; -P*) PRINTER=`echo "$1" | sed "s%-P%%"`;; ################################################################################ # -s Create a symbolic link from the spool area to # the data files rather than trying to copy # them (so large files can be printed). This # means the data files should not be modified # or removed until they have been printed. # This option can be used to avoid truncating # files larger than the maximum given in the mx # capability of the printcap(5) entry. -s only # prevents copies of local files from being # made. Jobs from remote hosts are copied any- # way. -s only works with named data files; if # the lpr command is at the end of a pipeline, # the data is copied to the spool. ################################################################################ -s) LINK="";; ################################################################################ # # -#copies Produce the number of copies indicated for # each named file. For example: # # example% lpr -#3 index.c lookup.c # # produces three copies of index.c, followed by # three copies of lookup.c. On the other hand, # # example% cat index.c lookup.c | lpr -#3 # # generates three copies of the concatenation # of the files. ################################################################################ -#) COPIES="$2"; if [ "$COPIES" = "" ]; then echo "lpr: Error: No number specified following -#." >&2 echo "$usage" >&2 exit 1 fi shift;; -#*) COPIES=`echo "$1" | sed "s%-#%%"`;; ################################################################################ # -Jjob Print job as the job name on the burst page. # Normally, lpr uses the first file's name. ################################################################################ -J) JOBTITLE="$2"; shift;; -J*) JOBTITLE=`echo "$1" | sed "s%-J%%"`;; ################################################################################ # -Cclass Print class as the job classification on the # burst page. For example, # # example% lpr -C Operations new.index.c # # replaces the system name (the name returned # by hostname) with "Operations" on the burst # page, and prints the file new.index.c. ################################################################################ -C) CLASS="$2"; shift;; -C*) CLASS=`echo "$1" | sed "s%-C%%"`;; ################################################################################ # -Ttitle Use title instead of the file name for the # title used by pr(1V). ################################################################################ -T) TITLE="$2"; shift;; -T*) TITLE=`echo "$1" | sed "s%-T%%"`;; ################################################################################ # -wcols Use cols as the page width for pr. ################################################################################ -w) WIDE="$2"; if [ "$WIDE" = "" ]; then echo "lpr: Error: No number specified following -w." >&2 echo "$usage" >&2 exit 1 fi shift;; -w*) WIDE=`echo "$1" | sed "s%-w%%"`;; ################################################################################ # -h Suppress printing the burst page. ################################################################################ -h) HEADER="-oBSDh";; ################################################################################ # filter-option The following single letter options notify # the line printer spooler that the files are # not standard text files. The spooling daemon # will use the appropriate filters to print the # data accordingly. # # -p Use pr to format the files (lpr -p is # very much like `pr | lpr'). # -l Print control characters and suppress # page breaks. # -t The files contain troff(1) (cat photo- # typesetter) binary data. # -n The files contain data from ditroff # (device independent troff). # -d The files contain data from tex (DVI # format from Stanford). # -g The files contain standard plot data as # produced by the plot(3X) routines (see # also plot(1G) for the filters used by # the printer spooler). # -v The files contain a raster image, see # rasterfile(5). The printer must support # an appropriate imaging model such as # PostScript in order to print the image. # -c The files contain data produced by cif- # plot. # -f Interpret the first character of each # line as a standard FORTRAN carriage con- # trol character. # # If no filter-option is given (and the printer # can interpret PostScript), the string `%!' as # the first two characters of a file indicates # that it contains PostScript commands. ################################################################################ -p|-l|-t|-n|-d|-g|-v|-c|-f) LETTER=`echo $1|sed "s%-%%"` FILTER="-oBSD$LETTER" ;; ################################################################################ # # -m Send mail upon completion. # -m) MAIL="-oBSDm" ;; ################################################################################ # # -i[ indent ] Indent output indent SPACE characters. Eight # SPACE characters is the default. The indent # is passed to the input filter. If no input # filter is present, this option is ignored. ################################################################################ -i) INDENT="$2"; shift;; -i*) INDENT=`echo "$1" | sed "s%-i%%"`;; ################################################################################ # other options (ignore) -*) echo "WARNING: $1 not implemented and/or available ">&2 echo "$usage" >&2 shift;; ################################################################################ # file name *) FILES="$FILES $1";; ################################################################################ esac shift done CLASS=${CLASS:+-oBSDC\'$CLASS\'} JOBTITLE=${JOBTITLE:+-oBSDJ\'$JOBTITLE\'} TITLE=${TITLE:+-oBSDT\'$TITLE\'} INDENT=${INDENT:+-oBSDi$INDENT} ################################################################################ set -x lp -d${PRINTER} $MAIL $LINK $INDENT -n${COPIES} $CLASS $JOBTITLE $TITLE -oBSDw${WIDE} $FILTER $HEADER $FILES exit ################################################################################