1
0

lp.ms 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. .HTML "A Guide to the Lp Printer Spooler
  2. .TL
  3. A Guide to the Lp
  4. Printer Spooler
  5. .AU
  6. Paul Glick
  7. pg@plan9.bell-labs.com
  8. .AB
  9. .PP
  10. .I Lp
  11. is a collection of programs used to provide an easy-to-use
  12. interface for printing a variety of document types on a variety
  13. of printers.
  14. .I Lp
  15. is the glue that connects various document language
  16. translators and printer communication programs together so that
  17. the users may have a consistent view of printers.
  18. Most of the glue
  19. is shell script, which can be easily modified.
  20. The user need not
  21. specify options to get sensible output in most cases.
  22. .I Lp
  23. is described here
  24. so that others may make additions and changes.
  25. .AE
  26. \" .2C
  27. .NH
  28. Introduction
  29. .PP
  30. .I Lp
  31. is used to format and print data on a variety of output devices.
  32. The need for
  33. .I lp
  34. was rooted in the inability of other printer spoolers to do simple
  35. tasks without a great deal of user specification of options.
  36. At the time
  37. .I lp
  38. was written, there were several printer
  39. languages, such as ImPress and PostScript, and
  40. an internally developed printer that would accept
  41. .I troff
  42. output.
  43. Now, all our printers take PostScript,
  44. but printers that use HPCL and HPGL abound and
  45. support for those printers may be added easily.
  46. A great deal of what underlies
  47. .I lp
  48. is taken from BSD's
  49. .I lpr
  50. and System V's
  51. .I lp .
  52. The important features of this system are that most of the programs
  53. are easily modified shell scripts and the user need not
  54. learn to use the large amount of underlying software developed by others.
  55. .I Lp
  56. runs under Plan 9 and several flavors of
  57. UNIX.
  58. This document deals with
  59. .I lp
  60. as it relates to Plan 9.
  61. .I Lp
  62. was developed using both Datakit and Ethernet to transport data between machines.
  63. Now only the Ethernet transport mechanism remains.
  64. .PP
  65. Text, graphics, and formatted text files are appropriately processed and
  66. placed into a spool directory from which they are taken to be printed by a daemon process.
  67. Additional functions include checking the status of a printer queue
  68. and removing jobs from the printer queue.
  69. .PP
  70. All the shell scripts (see
  71. .I rc (1))
  72. associated with
  73. .I lp
  74. reside in the spool directory
  75. .CW /sys/lib/lp
  76. except for the
  77. .I lp
  78. command itself, which resides in
  79. .CW /rc/bin .
  80. Commands related to
  81. .I lp
  82. that are not shell scripts can most often be found
  83. in
  84. .CW /$cputype/bin/aux .
  85. The directory where all the
  86. .I lp
  87. scripts reside is defined within
  88. .I lp
  89. by the shell variable
  90. .CW LPLIB .
  91. In the remainder of this document, file names will be specified
  92. with this shell variable as their root.
  93. .NH
  94. Usage
  95. .PP
  96. .I Lp
  97. requires an output device to be specified
  98. before it will process input.
  99. This can be done in any of three ways described here.
  100. .IP 1)
  101. The file
  102. .CW $LPLIB/defdevice
  103. may contain the name of a default output device.
  104. This may not be practical for environments where
  105. there are many printers.
  106. .IP 2)
  107. The user's environment variable
  108. .CW LPDEST
  109. may be set to the name of the device to be used.
  110. This is often a more practical solution when there are several printers
  111. available.
  112. This overrides a
  113. .CW defdevice
  114. specification.
  115. .IP 3)
  116. The
  117. .CW -d
  118. .I printer
  119. option to the
  120. .I lp
  121. command specifies
  122. .I printer
  123. as the device to which output should be directed, overriding the
  124. previous two specifications.
  125. .PP
  126. .ti 0
  127. If
  128. .I printer
  129. is
  130. .CW ? ,
  131. a list of printers and other information in the
  132. .CW devices
  133. file is printed, as shown in Figure 1.
  134. Quote the question mark to prevent it from being
  135. interpreted by the shell language as a metacharacter.
  136. \" .1C
  137. .KF
  138. .P1
  139. % lp -d'?'
  140. device location host class
  141. fn 2C-501 helix post/2+600dpi+duplex
  142. pcclone - - post+nohead
  143. peacock 2C-501 cetus post/2+300dpi+nohead+color
  144. ps83 st8_fl3 rice post+300dpi+reverse
  145. psu 2C-501 cetus post/2+1200dpi
  146. .
  147. .
  148. .
  149. %
  150. .P2
  151. .ce
  152. .I "Figure 1. Sample listing of installed printers"
  153. .KE
  154. .PP
  155. Normally,
  156. .I lp
  157. uses the
  158. .CW file
  159. command to figure out what type of input it is receiving.
  160. This is done within the
  161. .CW generic
  162. process which is discussed later in this paper in the
  163. .B "Process directory"
  164. section.
  165. To select a specific input processor the
  166. \f(CW-p\fP\fIprocess\fP
  167. option is used where
  168. .I process
  169. is one of the shell scripts in the
  170. .CW process
  171. directory.
  172. .LP
  173. Troff
  174. output can be printed, in this case, on printer
  175. .I fn
  176. with
  177. .P1
  178. % troff -ms lp.ms | lp -dfn
  179. .P2
  180. .LP
  181. A file can be converted to PostScript using the pseudo-printer
  182. .CW stdout :
  183. .P1
  184. % troff -ms lp.ms | lp -dstdout > lp.ps
  185. .P2
  186. LaTeX (and analogously TeX)
  187. documents are printed in two steps:
  188. .P1
  189. % latex lp.tex
  190. .
  191. .
  192. % lp lp.dvi
  193. .
  194. .
  195. %
  196. .P2
  197. LaTeX
  198. produces a `.dvi' file and
  199. does not permit the use of a pipe
  200. connection to the standard input of
  201. .I lp .
  202. To look at the status and queue of a device, use
  203. .CW -q :
  204. .P1
  205. % lp -dpsu -q
  206. daemon status:
  207. : 67.17% sent
  208. printer status:
  209. %%[ status: busy; source: lpd ]%%
  210. queue on cetus:
  211. job user try size
  212. rice29436.1 pg 0 17454
  213. slocum17565.1 ches 1 49995
  214. %
  215. .P2
  216. This command can print the status and queue of the local
  217. and remote hosts.
  218. Administrators should be advised that working in an environment where the
  219. .I lp
  220. spool directory is shared among the local and remote hosts,
  221. no spooling should be done on the local hosts.
  222. The format of the status and queue printout is up to the administrator.
  223. The job started above can be killed with
  224. .CW -k :
  225. .P1
  226. $ lp -dpsu -k rice29436.1
  227. rice29436.1 removed from psu queue on cetus
  228. .P2
  229. .NH
  230. Options
  231. .PP
  232. There are options available to modify the way in which a job is handled.
  233. It is the job of the
  234. .I lp
  235. programs to convert the option settings so they may be used by each of the
  236. different translation and interface programs.
  237. Not all options are applicable to all printer environments.
  238. Table 1 lists the standard
  239. .I lp
  240. options, the shell variable settings, and description of the options.
  241. \" .1C
  242. .KF
  243. .sp
  244. .in 0
  245. .TS
  246. center;
  247. c | c s s | c
  248. c | c c c | c
  249. lfCWp-2 | lfCWp-2 cfCWp-2 cfCWp-2 | lp-2w(3i).
  250. =
  251. option shell variable action
  252. \^ name default set \^
  253. _
  254. -D DEBUG N 1 turn on debugging mode.
  255. _
  256. -H NOHEADER N 1 suppress header page.
  257. _
  258. -L LAND N 1 make long page dimension horizontal.
  259. _
  260. -M \fImach\fP LPMACHID N \fImach\fP set the source machine name.
  261. _
  262. -Q QONLY N 1 do not execute daemon; for debugging.
  263. _
  264. -c \fIn\fP COPIES N \fIn\fP number of copies to be printed.
  265. _
  266. -d \fIprinter\fP LPDEST U \fIprinter\fP set job destination; override other settings.
  267. _
  268. -f \fIfont.pt\fP FONT N \fIfont\fP set font style and point size for printing.
  269. POINT N \fIpt\fP
  270. _
  271. -i \fIn\fP IBIN N \fIn\fP T{
  272. select input paper tray options.
  273. The argument given is dependent on the printer type.
  274. A number can be given to select a particular tray and/or
  275. .CW simplex
  276. or
  277. .CW duplex
  278. may be used to get single or double sided output, where
  279. applicable.
  280. Multiple options should be separated by commas.
  281. T}
  282. _
  283. -k KILLFLAG 0 1 T{
  284. take non-option arguments as job numbers to be removed from queue.
  285. T}
  286. _
  287. -l \fIn\fP LINES N \fIn\fP T{
  288. for printed data, the number of lines per logical page.
  289. T}
  290. _
  291. -m \fIf\fP MAG N \fIf\fP T{
  292. magnify the image by a factor \fIf\fP.
  293. The factor should be a positive real number.
  294. T}
  295. _
  296. -n \fIn\fP NPAG N \fIn\fP T{
  297. put \fIn\fP logical pages on a single physical page.
  298. A simple algorithm is used to pack the pages.
  299. T}
  300. _
  301. -o \fIlist\fP OLIST N \fIlist\fP T{
  302. print only those pages specified in the list.
  303. The list may be a sequence of numbers or ranges separated by commas.
  304. A range is a pair of numbers separated by a hyphen.
  305. T}
  306. _
  307. -p \fIproc\fP LPPROC L \fIproc\fP T{
  308. use the preprocessor \fIproc\fP instead of the preprocessor given
  309. in the
  310. .CW devices
  311. file for this printer.
  312. T}
  313. _
  314. -q LPQ N 1 T{
  315. print the status and queue.
  316. T}
  317. _
  318. -r REVERSE L 1 T{
  319. this toggles the
  320. .CW REVERSE
  321. flag, changing whether or not page reversal should occur in preprocessing.
  322. Page reversal is needed if a printer delivers pages face up.
  323. The keyword
  324. .CW reverse
  325. can be placed in the
  326. .I lpclass
  327. field of the
  328. .CW devices
  329. file.
  330. If a document has already been processed this flag has no effect.
  331. T}
  332. _
  333. -u \fIuser\fP LPUSERID U \fIuser\fP T{
  334. change the user id that appears on the cover page.
  335. T}
  336. _
  337. -x \fIoffset\fP XOFF N \fIoffset\fP T{
  338. move the image \fIoffset\fP inches to the right.
  339. A negative \fIoffset\fP will move the image to the left.
  340. The \fIoffset\fP may be any reasonable real number.
  341. T}
  342. _
  343. -y \fIoffset\fP YOFF N \fIoffset\fP T{
  344. same as for
  345. .CW -x
  346. except a positive offset will move the image down.
  347. T}
  348. _
  349. .T&
  350. l l cp-2 lp-2 s
  351. l l cfCWp-2 lp-2 s.
  352. .vs -2p
  353. default setting definition
  354. N set to the null string (`') initially in \fIlp\fP.
  355. L set from printer entry in \f(CW\\s-\\n(XPdevices\\s+\\n(XP\fP file.
  356. U set from the user's environment.
  357. .vs +2p
  358. .TE
  359. .sp
  360. .ce
  361. .I "Table 1. Lp Option List"
  362. .sp
  363. .ll \\n(LLu
  364. .KE
  365. \" .2C
  366. .NH
  367. Devices file
  368. .PP
  369. The
  370. .CW devices
  371. file is found in the spool directory.
  372. Each line in the file is composed of 12 fields, separated
  373. by tabs or spaces, that describe the attributes
  374. of the printer and how it should be serviced.
  375. Within the
  376. .CW lp
  377. command, a shell variable is set for each attribute;
  378. the following list describes them:
  379. .IP "\f(CW\s-\n(XPLPDEST\s+\n(XP\fP " 12
  380. is the name of the device as given to
  381. .I lp
  382. with the
  383. .CW -d
  384. option
  385. or as specified by the shell environment variable
  386. .CW LPDEST
  387. or as specified by
  388. the file
  389. .CW $LPLIB/defdevice .
  390. This name is used in creating directories and log files that are associated with
  391. the printers operation.
  392. .IP "\f(CW\s-\n(XPLOC\s+\n(XP\fP "
  393. just describes where the printer is physically located.
  394. .IP "\f(CW\s-\n(XPDEST_HOST\s+\n(XP\fP "
  395. is the host from which the files are printed.
  396. Files may be spooled on other machines before being transferred to the
  397. destination host.
  398. .IP "\f(CW\s-\n(XPOUT_DEV\s+\n(XP\fP "
  399. is the physical device name or network address needed by the printer daemon
  400. to connect to the printer.
  401. This field depends on the requirements of the daemon and may contain a `\(en'
  402. if not required.
  403. .IP "\f(CW\s-\n(XPSPEED\s+\n(XP\fP "
  404. is the baud rate setting for the port.
  405. This field depends on the requirements of the daemon and may contain a `\(en'
  406. if not required.
  407. .IP "\f(CW\s-\n(XPLPCLASS\s+\n(XP\fP "
  408. is used to encode minor printer differences.
  409. The keyword
  410. .CW reverse
  411. is used by some of the preprocessors
  412. to reverse the order the pages are printed to accommodate different output
  413. trays (either face up or face down).
  414. The keyword
  415. .CW nohead
  416. is used to suppress the header page.
  417. This is used for special and color printers.
  418. The keyword
  419. .CW duplex
  420. is used to coax double sided output from duplex printers.
  421. .IP "\f(CW\s-\n(XPLPPROC\s+\n(XP\fP "
  422. is the command from the
  423. .CW LPLIB/process
  424. directory to be used to convert input to a format
  425. that will be accepted by the device.
  426. The preprocessor is invoked by the spooler.
  427. .IP "\f(CW\s-\n(XPSPOOLER\s+\n(XP\fP "
  428. is the command from the
  429. .CW LPLIB/spooler
  430. directory which will select files using the
  431. .CW SCHED
  432. command and invoke the
  433. .CW LPPROC
  434. command, putting its output
  435. into the remote spool directory.
  436. The output is sent directly to the spool directory on the
  437. destination machine to avoid conflicts when client and
  438. server machines share spool directories.
  439. .IP "\f(CW\s-\n(XPSTAT\s+\n(XP\fP "
  440. is the command from the
  441. .CW LPLIB/stat
  442. directory that prints the status of the device and the list of jobs
  443. waiting on the queue for the device.
  444. The status information depends on what is available from the printer
  445. and interface software.
  446. The queue information should be changed to show information
  447. useful in tracking down problems.
  448. The
  449. .CW SCHED
  450. command is used to show the jobs in the order
  451. in which they will be printed.
  452. .IP "\f(CW\s-\n(XPKILL\s+\n(XP\fP "
  453. is the command from the
  454. .CW LPLIB/kill
  455. that removes jobs from the queue.
  456. The jobs to be removed are given as arguments to the
  457. .I lp
  458. command.
  459. When possible, it should also abort the currently running job
  460. if it has to be killed.
  461. .IP "\f(CW\s-\n(XPDAEMON\s+\n(XP\fP "
  462. is the command from the
  463. .CW LPLIB/daemon
  464. that is meant to run asynchronously to remove
  465. jobs from the queue.
  466. Jobs may either be passed on to another host or sent to the
  467. printing device.
  468. .I Lp
  469. always tries to start a daemon process when one is specified.
  470. .IP "\f(CW\s-\n(XPSCHED\s+\n(XP\fP "
  471. is the command from the
  472. .CW LPLIB/sched
  473. that is used to present the job names to the
  474. daemon and stat programs
  475. in some order, e.g., first-in-first-out, smallest first.
  476. .NH
  477. Support programs
  478. .PP
  479. The following sections describe the basic functions of the programs
  480. that are found in the subdirectories of
  481. .CW $LPLIB .
  482. The programs in a specific directory vary with the
  483. type of output device or networks that have to be used.
  484. .NH 2
  485. Process directory
  486. .PP
  487. The
  488. .CW generic
  489. preprocessor
  490. is the default preprocessor for most printers.
  491. It uses the
  492. .I file (1)
  493. command to determine the format of the input file.
  494. The appropriate preprocessor is then selected to transform the
  495. file to a format suitable for the printer.
  496. .PP
  497. Here is a list of some of the preprocessors and
  498. a description of their function.
  499. A complete list of preprocessors and their descriptions can be found in the manual page
  500. .I lp (8).
  501. .sp
  502. .IP \f(CWdvipost\fP 14
  503. Converts TeX or LaTeX output (\f(CW.dvi\fP files) to PostScript
  504. .IP \f(CWppost\fP
  505. Converts UTF text to PostScript.
  506. The default font is Courier with Lucida fonts filling in
  507. the remainder of the (available) Unicode character space.
  508. .IP \f(CWtr2post\fP
  509. Converts (device independent) troff output for the device type
  510. .CW utf .
  511. See
  512. .CW /sys/lib/troff/font/devutf
  513. directory for troff font width table descriptions.
  514. See also the
  515. .CW /sys/lib/postscript/troff
  516. directory for mappings of
  517. troff
  518. .CW UTF
  519. character space to PostScript font space.
  520. .IP \f(CWp9bitpost\fP
  521. Converts Plan 9 bitmaps (see
  522. .I bitfile (9.6))
  523. to PostScript.
  524. .IP \f(CWg3post\fP
  525. Converts fax (CCITT-G31 format) to PostScript.
  526. .IP \f(CWhpost\fP
  527. Does header page processing and page reversal processing, if
  528. necessary.
  529. Page reversal is done here so the header page always comes
  530. out at the beginning of the job.
  531. Header page processing is very location-dependent.
  532. .NH 2
  533. Spool directory
  534. .PP
  535. The
  536. .CW generic
  537. spooler is responsible for executing the preprocessor
  538. and directing its output to a file in the printer's queue.
  539. An additional file is created containing information such as the system name,
  540. user id, job number, and number of times this job was attempted.
  541. .PP
  542. Certain printer handling programs do not require separate
  543. preprocessing and spooling.
  544. For such circumstances a
  545. .CW nospool
  546. spooler is available that just executes the preprocessing program.
  547. The processing and spooling functions are assumed by this program and the output is sent to
  548. .CW OUT_DEV
  549. or standard output if
  550. .CW OUT_DEV
  551. is '-'.
  552. .PP
  553. The
  554. .CW pcclone
  555. spooler is used to send print jobs directly to a printer connected
  556. to a 386 compatible printer port (See
  557. .I lpt (3)).
  558. .NH 2
  559. Stat directory
  560. .PP
  561. The function of the shell scripts in the
  562. .CW stat
  563. directory is to present status information about the
  564. printer and its queue.
  565. When necessary, the
  566. .CW stat
  567. scripts may be designed
  568. to return information about the local queue as well as the remote queue.
  569. This is not done on Plan 9 because many systems share the same queue directory.
  570. The scheduler is used to print the queue in the order in which the jobs
  571. will be executed.
  572. .NH 2
  573. Kill directory
  574. .PP
  575. The
  576. .CW kill
  577. scripts receive command line arguments passed to them by
  578. .I lp
  579. and remove the job and id files which match the arguments
  580. for the particular queue.
  581. When a job is killed, the generic kill procedure:
  582. .IP 1)
  583. kills the daemon for this queue if the job being killed
  584. is first in the queue,
  585. .IP 2)
  586. removes the files associated with the job from the queue,
  587. .IP 3)
  588. attempts to restart the daemon.
  589. .NH 2
  590. Daemon directory
  591. .PP
  592. The
  593. .CW daemon
  594. shell scripts are the last to be invoked by
  595. .I lp
  596. if the
  597. .CW -Q
  598. option has not been given.
  599. The daemon process is executed asynchronously
  600. with its standard output and standard error appended to
  601. the printer log file.
  602. The log file is described in a subsequent section.
  603. Because the daemon runs asynchronously, it must
  604. catch signals that could cause it to terminate abnormally.
  605. The daemon first checks to see that it is the only one running
  606. by using the
  607. .CW LOCK
  608. program found in the
  609. .CW /$cputype/bin/aux
  610. directory.
  611. The
  612. .CW LOCK
  613. command creates a
  614. .CW LOCK
  615. file in the printer's queue directory.
  616. The daemon then executes the scheduler to obtain the name of the
  617. next job on the queue.
  618. .PP
  619. The processing of jobs may entail transfer to another host
  620. or transmission to a printer.
  621. The details of this are specific to the individual daemons.
  622. If a job is processed without error, it is removed from the queue.
  623. If a job does not succeed, the associated files may be
  624. moved to a printer specific directory in
  625. .CW $LPLIB/prob .
  626. In either case, the daemon can make an entry in the printer's
  627. log file.
  628. Before exiting, the daemon should clean up lock files by calling
  629. .CW UNLOCK .
  630. .PP
  631. Several non-standard daemon programs have been designed
  632. to suit various requirements and whims.
  633. One such program announces job completion and empty paper trays
  634. by causing icons to appear in peoples'
  635. .CW seemail
  636. window.
  637. Another, using a voice synthesizer, makes verbal announcements.
  638. Other daemons may be designed to taste.
  639. .NH 2
  640. Sched directory
  641. .PP
  642. The scheduler must decide which job files should be executed and
  643. in what order.
  644. The most commonly used scheduler program is
  645. .CW FIFO ,
  646. which looks like this:
  647. .P1
  648. ls -tr $* | sed -n -e 's/.* *//' \e
  649. -e '/^[0-9][0-9]*\.[1-9][0-9]*$/p'
  650. .P2
  651. This lists all the job files in this printer's queue in modification
  652. time order.
  653. Jobs entering the queue have a dot (.) prefixed to their name
  654. to keep the scheduler from selecting them before they are complete.
  655. .NH
  656. Where Things Go Wrong
  657. .PP
  658. There are four directories where
  659. .I lp
  660. writes files.
  661. On the Plan 9 release these directories may be found
  662. in a directory on a scratch filesystem that is not
  663. backed-up.
  664. This directory is
  665. .CW /n/emelieother/lp .
  666. It is built on top of a file system
  667. .CW other
  668. that is mounted on the file server
  669. .CW emelie .
  670. The four directories in
  671. this scratch directory
  672. are
  673. .CW log ,
  674. .CW prob ,
  675. .CW queue ,
  676. and
  677. .CW tmp .
  678. .I Lp
  679. binds (see
  680. .I bind (1))
  681. the first three into the directory
  682. .CW /sys/lib/lp
  683. for its processes and their children.
  684. The
  685. .CW tmp
  686. directory is bound to the
  687. .CW /tmp
  688. directory so that the lp daemons, which run as user `none',
  689. may write into this directory.
  690. .PP
  691. On any new installation, it is important that these directories
  692. be set up and that the
  693. .I /rc/bin/lp
  694. command be editted to reflect the change.
  695. If you do not have a scratch filesystem for these directories,
  696. create the four directories
  697. .CW log ,
  698. .CW prob ,
  699. .CW queue ,
  700. and
  701. .CW tmp
  702. in
  703. .CW $LPLIB
  704. .CW (/sys/lib/lp)
  705. so that they are writable by anyone.
  706. .NH 2
  707. Log directory
  708. .PP
  709. The log files for a particular
  710. .I printer
  711. appear in a subdirectory of the spool directory
  712. \f(CWlog\fP/\fIprinter\fP.
  713. There are currently two types of log files.
  714. One is for the daemon to log errors and successful completions
  715. of jobs.
  716. These are named
  717. .I printer.day
  718. where
  719. .I day
  720. is the three letter abbreviation for the day of the week.
  721. These are overwritten once a week to avoid the need for regular
  722. cleanup.
  723. The other type of log file contains the status of the printer and
  724. is written by the program that communicates with the printer itself.
  725. These are named
  726. \fIprinter\fP.\f(CWst\fP.
  727. These are overwritten with each new job and are saved in the
  728. .CW $LPLIB/prob
  729. directory along with the job under circumstances described below.
  730. When a printer does not appear to be functioning these files are the
  731. place to look first.
  732. .NH 2
  733. Prob directory
  734. .PP
  735. When a job fails to produce output,
  736. the log files should be checked for any obvious problems.
  737. If none can be found, a directory with full read and write permissions
  738. should be created with the name of the printer in the
  739. .CW $LPLIB/prob
  740. directory.
  741. Subsequent failure of a job will cause the daemon to leave a
  742. copy of the job and the printer communication log in
  743. \f(CW$LPLIB/prob/\fP\fIprinter\fP
  744. directory.
  745. It is common for a printer to enter states from which
  746. it cannot be rescued except by manually cycling the power on the printer.
  747. After this is done the print daemon should recover by itself
  748. (give it a minute).
  749. If it does not recover, remove the
  750. .CW LOCK
  751. file from the printer's spool directory to kill the daemon.
  752. The daemon will have to be restarted by sending another job
  753. to the printer.
  754. For PostScript printers just use:
  755. .P1
  756. echo '%!PS' | lp
  757. .P2
  758. .NH 2
  759. Repairing Stuck Daemons
  760. .PP
  761. There are conditions that occur which are not handled
  762. by the daemons.
  763. One such problem can only be described as the printer entering a
  764. comatose state.
  765. The printer does not respond to any messages sent to it.
  766. The daemon should recover from the reset and an error message
  767. will appear in the log files.
  768. If all else fails, one can kill the first job in the queue
  769. or remove the
  770. .CW LOCK
  771. file from the queue directory.
  772. This will kill the daemon, which will have to be restarted.
  773. .NH
  774. Interprocessor Communication
  775. .PP
  776. A Plan 9 CPU server can be set up as a printer's spooling host.
  777. That is, the machine where jobs are spooled and from which those jobs
  778. are sent directly to the printer.
  779. To do this, the CPU must listen on TCP port 515 which is the well known
  780. port for the BSD line printer daemon.
  781. The file
  782. .CW /rc/bin/service/tcp515
  783. is executed when a call comes in on that port.
  784. The Plan 9
  785. .CW lpdaemon
  786. will accept jobs sent from BSD LPR/LPD systems.
  787. The
  788. .CW /$cputype/bin/aux/lpdaemon
  789. command is executed from the service call and it accepts print jobs, requests for status,
  790. and requests to kill jobs.
  791. The command
  792. .CW /$cputype/bin/aux/lpsend
  793. is used to send jobs
  794. to other Plan 9 machines and is usually called from
  795. within a spooler or daemon script.
  796. The command
  797. .CW /$cputype/bin/aux/lpdsend
  798. is used to send jobs
  799. to machines and printers that use the BSD LPR/LPD protocol and is also usually called from
  800. within a spooler or daemon script.
  801. .NH
  802. Acknowledgements
  803. .PP
  804. Special thanks to Rich Drechsler for supplying and maintaining most of
  805. the PostScript translation and interface programs,
  806. without which
  807. .I lp
  808. would be an empty shell.
  809. Tomas Rokicki provided the
  810. TeX
  811. to PostScript
  812. translation program.
  813. .NH
  814. References
  815. .LP
  816. [Camp86] Ralph Campbell,
  817. ``4.3BSD Line Printer Spooler Manual'', UNIX System Manager's Manual,
  818. May, 1986, Berkeley, CA
  819. .br
  820. [RFC1179] Request for Comments: 1179, Line Printer Daemon Protocol, Aug 1990
  821. .br
  822. [Sys5] System V manual, date unknown