824 lines · 21.9 KB · Text
RawDownload
.HTML "A Guide to the Lp Printer Spooler.TLA Guide to the LpPrinter Spooler.AUPaul Glickpg@plan9.bell-labs.com.AB.PP.I Lpis a collection of programs used to provide an easy-to-useinterface for printing a variety of document types on a varietyof printers..I Lpis the glue that connects various document languagetranslators and printer communication programs together so thatthe users may have a consistent view of printers.Most of the glueis shell script, which can be easily modified.The user need notspecify options to get sensible output in most cases..I Lpis described hereso that others may make additions and changes..AE\" .2C.NHIntroduction.PP.I Lpis used to format and print data on a variety of output devices.The need for.I lpwas rooted in the inability of other printer spoolers to do simpletasks without a great deal of user specification of options.At the time.I lpwas written, there were several printerlanguages, such as ImPress and PostScript, andan internally developed printer that would accept.I troffoutput.Now, all our printers take PostScript,but printers that use HPCL and HPGL abound andsupport for those printers may be added easily.A great deal of what underlies.I lpis taken from BSD's.I lprand System V's.I lp .The important features of this system are that most of the programsare easily modified shell scripts and the user need notlearn to use the large amount of underlying software developed by others..I Lpruns under Plan 9 and several flavors ofUNIX.This document deals with.I lpas it relates to Plan 9..I Lpwas developed using both Datakit and Ethernet to transport data between machines.Now only the Ethernet transport mechanism remains..PPText, graphics, and formatted text files are appropriately processed andplaced into a spool directory from which they are taken to be printed by a daemon process.Additional functions include checking the status of a printer queueand removing jobs from the printer queue..PPAll the shell scripts (see.I rc (1))associated with.I lpreside in the spool directory.CW /sys/lib/lpexcept for the.I lpcommand itself, which resides in.CW /rc/bin .Commands related to.I lpthat are not shell scripts can most often be foundin.CW /$cputype/bin/aux .The directory where all the.I lpscripts  reside is defined within.I lpby the shell variable.CW LPLIB .In the remainder of this document, file names will be specifiedwith this shell variable as their root..NHUsage.PP.I Lprequires an output device to be specifiedbefore it will process input.This can be done in any of three ways described here..IP 1)The file.CW $LPLIB/defdevicemay contain the name of a default output device.This may not be practical for environments wherethere are many printers..IP 2)The user's environment variable.CW LPDESTmay be set to the name of the device to be used.This is often a more practical solution when there are several printersavailable.This overrides a.CW defdevicespecification..IP 3)The.CW -d.I printeroption to the.I lpcommand specifies.I printeras the device to which output should be directed, overriding theprevious two specifications..PP.ti 0If.I printeris.CW ? ,a list of printers and other information in the.CW devicesfile is printed, as shown in Figure 1.Quote the question mark to prevent it from beinginterpreted by the shell language as a metacharacter.\" .1C.KF.P1% lp -d'?'device   location  host             classfn       2C-501    helix            post/2+600dpi+duplexpcclone  -         -                post+noheadpeacock  2C-501    cetus            post/2+300dpi+nohead+colorps83     st8_fl3   rice             post+300dpi+reversepsu      2C-501    cetus            post/2+1200dpi     .     .     .%.P2.ce.I "Figure 1.  Sample listing of installed printers".KE.PPNormally,.I lpuses the.CW filecommand to figure out what type of input it is receiving.This is done within the.CW genericprocess which is discussed later in this paper in the.B "Process directory"section.To select a specific input processor the\f(CW-p\fP\fIprocess\fPoption is used where.I processis one of the shell scripts in the.CW processdirectory..LPTroffoutput can be printed, in this case, on printer.I fnwith.P1% troff -ms lp.ms | lp -dfn.P2.LPA file can be converted to PostScript using the pseudo-printer.CW stdout :.P1% troff -ms lp.ms | lp -dstdout > lp.ps.P2LaTeX (and analogously TeX)documents are printed in two steps:.P1% latex lp.tex     .     .% lp lp.dvi     .     .%.P2LaTeXproduces a `.dvi' file anddoes not permit the use of a pipeconnection to the standard input of.I lp .To look at the status and queue of a device, use.CW -q :.P1% lp -dpsu -qdaemon status::  67.17% sentprinter status:%%[ status: busy; source: lpd ]%% queue on cetus:job		user	try	sizerice29436.1	pg	0	17454slocum17565.1	ches	1	49995%.P2This command can print the status and queue of the localand remote hosts.Administrators should be advised that working in an environment where the.I lpspool directory is shared among the local and remote hosts,no spooling should be done on the local hosts.The format of the status and queue printout is up to the administrator.The job started above can be killed with.CW -k :.P1$ lp -dpsu -k rice29436.1rice29436.1 removed from psu queue on cetus.P2.NHOptions.PPThere are options available to modify the way in which a job is handled.It is the job of the.I lpprograms to convert the option settings so they may be used by each of thedifferent translation and interface programs.Not all options are applicable to all printer environments.Table 1 lists the standard.I lpoptions, the shell variable settings, and description of the options.\" .1C.KF.sp.in 0.TScenter;c | c s s | cc | c c c | clfCWp-2 | lfCWp-2 cfCWp-2 cfCWp-2 | lp-2w(3i).=option	shell variable	action\^	name	default	set	\^_-D	DEBUG	N	1	turn on debugging mode._-H	NOHEADER	N	1	suppress header page._-L	LAND	N	1	make long page dimension horizontal._-M \fImach\fP	LPMACHID	N	\fImach\fP	set the source machine name._-Q	QONLY	N	1	do not execute daemon; for debugging._-c \fIn\fP	COPIES	N	\fIn\fP	number of copies to be printed._-d \fIprinter\fP	LPDEST	U	\fIprinter\fP	set job destination; override other settings._-f \fIfont.pt\fP	FONT	N	\fIfont\fP	set font style and point size for printing.	POINT	N	\fIpt\fP_-i \fIn\fP	IBIN	N	\fIn\fP	T{select input paper tray options.The argument given is dependent on the printer type.A number can be given to select a particular tray and/or.CW simplexor.CW duplexmay be used to get single or double sided output, whereapplicable.Multiple options should be separated by commas.T}_-k	KILLFLAG	0	1	T{take non-option arguments as job numbers to be removed from queue.T}_-l \fIn\fP	LINES	N	\fIn\fP	T{for printed data, the number of lines per logical page.T}_-m \fIf\fP	MAG	N	\fIf\fP	T{magnify the image by a factor \fIf\fP.The factor should be a positive real number.T}_-n \fIn\fP	NPAG	N	\fIn\fP	T{put \fIn\fP logical pages on a single physical page.A simple algorithm is used to pack the pages.T}_-o \fIlist\fP	OLIST	N	\fIlist\fP	T{print only those pages specified in the list.The list may be a sequence of numbers or ranges separated by commas.A range is a pair of numbers separated by a hyphen.T}_-p \fIproc\fP	LPPROC	L	\fIproc\fP	T{use the preprocessor \fIproc\fP instead of the preprocessor givenin the.CW devicesfile for this printer.T}_-q	LPQ	N	1	T{print the status and queue.T}_-r	REVERSE	L	1	T{this toggles the.CW REVERSEflag, changing whether or not page reversal should occur in preprocessing.Page reversal is needed if a printer delivers pages face up.The keyword.CW reversecan be placed in the.I lpclassfield of the.CW devicesfile.If a document has already been processed this flag has no effect.T}_-u \fIuser\fP	LPUSERID	U	\fIuser\fP	T{change the user id that appears on the cover page.T}_-x \fIoffset\fP	XOFF	N	\fIoffset\fP	T{move the image \fIoffset\fP inches to the right.A negative \fIoffset\fP will move the image to the left.The \fIoffset\fP may be any reasonable real number.T}_-y \fIoffset\fP	YOFF	N	\fIoffset\fP	T{same as for.CW -xexcept a positive offset will move the image down.T}_.T&l l cp-2 lp-2 sl l cfCWp-2 lp-2 s..vs -2p 		default	setting definition		N	set to the null string (`') initially in \fIlp\fP.		L	set from printer entry in \f(CW\\s-\\n(XPdevices\\s+\\n(XP\fP file.		U	set from the user's environment..vs +2p.TE.sp.ce.I "Table 1. Lp Option List".sp.ll \\n(LLu.KE\" .2C	.NHDevices file.PPThe.CW devicesfile is found in the spool directory.Each line in the file is composed of 12 fields, separatedby tabs or spaces, that describe the attributesof the printer and how it should be serviced.Within the.CW lpcommand, a shell variable is set for each attribute;the following list describes them:.IP "\f(CW\s-\n(XPLPDEST\s+\n(XP\fP " 12is the name of the device as given to.I lpwith the.CW -doptionor as specified by the shell environment variable.CW LPDESTor as specified bythe file.CW $LPLIB/defdevice .This name is used in creating directories and log files that are associated withthe printers operation..IP "\f(CW\s-\n(XPLOC\s+\n(XP\fP "just describes where the printer is physically located..IP "\f(CW\s-\n(XPDEST_HOST\s+\n(XP\fP "is the host from which the files are printed.Files may be spooled on other machines before being transferred to thedestination host..IP "\f(CW\s-\n(XPOUT_DEV\s+\n(XP\fP "is the physical device name or network address needed by the printer daemonto connect to the printer.This field depends on the requirements of the daemon and may contain a `\(en'if not required..IP "\f(CW\s-\n(XPSPEED\s+\n(XP\fP "is the baud rate setting for the port.This field depends on the requirements of the daemon and may contain a `\(en'if not required..IP "\f(CW\s-\n(XPLPCLASS\s+\n(XP\fP "is used to encode minor printer differences.The keyword.CW reverseis used by some of the preprocessorsto reverse the order the pages are printed to accommodate different outputtrays (either face up or face down).The keyword.CW noheadis used to suppress the header page.This is used for special and color printers.The keyword.CW duplexis used to coax double sided output from duplex printers..IP "\f(CW\s-\n(XPLPPROC\s+\n(XP\fP "is the command from the.CW LPLIB/processdirectory to be used to convert input to a formatthat will be accepted by the device.The preprocessor is invoked by the spooler..IP "\f(CW\s-\n(XPSPOOLER\s+\n(XP\fP "is the command from the.CW LPLIB/spoolerdirectory which will select files using the.CW SCHEDcommand and invoke the.CW LPPROCcommand, putting its outputinto the remote spool directory.The output is sent directly to the spool directory on thedestination machine to avoid conflicts when client andserver machines share spool directories..IP "\f(CW\s-\n(XPSTAT\s+\n(XP\fP "is the command from the.CW LPLIB/statdirectory that prints the status of the device and the list of jobswaiting on the queue for the device.The status information depends on what is available from the printerand interface software.The queue information should be changed to show informationuseful in tracking down problems.The.CW SCHEDcommand is used to show the jobs in the orderin which they will be printed..IP "\f(CW\s-\n(XPKILL\s+\n(XP\fP "is the command from the.CW LPLIB/killthat removes jobs from the queue.The jobs to be removed are given as arguments to the.I lpcommand.When possible, it should also abort the currently running jobif it has to be killed..IP "\f(CW\s-\n(XPDAEMON\s+\n(XP\fP "is the command from the.CW LPLIB/daemonthat is meant to run asynchronously to removejobs from the queue.Jobs may either be passed on to another host or sent to theprinting device..I Lpalways tries to start a daemon process when one is specified..IP "\f(CW\s-\n(XPSCHED\s+\n(XP\fP "is the command from the.CW LPLIB/schedthat is used to present the job names to thedaemon and stat programsin some order, e.g., first-in-first-out, smallest first..NHSupport programs.PPThe following sections describe the basic functions of the programsthat are found in the subdirectories of.CW $LPLIB .The programs in a specific directory vary with thetype of output device or networks that have to be used..NH 2Process directory.PPThe.CW genericpreprocessoris the default preprocessor for most printers.It uses the.I file (1)command to determine the format of the input file.The appropriate preprocessor is then selected to transform thefile to a format suitable for the printer..PPHere is a list of some of the preprocessors anda description of their function.

Lines 1–500 of 824.