lp.ms 22 KB

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