home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!uwm.edu!cray.csd.uwm.edu!wls
- From: wls@cray.csd.uwm.edu (Bill Stapleton)
- Newsgroups: comp.sys.sun.admin
- Subject: Re: print filter (/etc/printcap : if=) too persistent
- Date: 22 Jan 1993 17:04:07 GMT
- Organization: Computing Services, U of Wisc-Milwaukee
- Lines: 48
- Distribution: comp
- Message-ID: <1jp9e7INNre@uwm.edu>
- References: <PSHANNON.93Jan19131750@iapetus.cv.nrao.edu> <1993Jan21.180848.26090@pwcs.stpaul.gov>
- Reply-To: Bill Stapleton <wls@csd4.csd.uwm.edu>
- NNTP-Posting-Host: 129.89.6.69
-
- In article <1993Jan21.180848.26090@pwcs.stpaul.gov>, derekt@pwcs.stpaul.gov (Derek Terveer) writes:
- > I ran into the same problem before, and i agree that lpd seems to be
- > out-clevering itself in attempting to optimize its input queue if there
- > are jobs waiting at the completion of any particular job. I never
- > really found a solution that was elegant. I replaced the filter with a
- > hand written hack job that looked for various characters, etc. to start
- > a new job, but it never really worked 100% of the time. sigh.
-
- That's because you're "out-clevering" yourself assuming "lpd" works in a way
- much different from the way it actually works, which is a very much dumber
- way with none of the optimization stuff you allude to. The only way "lpd"
- knows which printer a file gets sent to is by what spool directory it's
- in. When you "lpr" a file, the printer name is used to find the proper
- spool directory, then is essentially thrown away. The jobs in the directory
- have no information about what printer they were sent to. Similarly, when
- "lpd" prints the queue for a printer, it uses the name to find the spool
- directory, and tries to make a lock file there. If it can lock the
- directory, it prints all of the files it finds there, unlocks, and quits.
- If it can't, then another "lpd" must already be printing the files, so it
- exits.
-
- Now, if you point two different printers to the same spool file, "lpd"
- won't even notice. Which ever printer entry happens to get started first
- will print everything in the directory on the printer pointed to by the
- entry it started with, including new files that arrive while it's working.
- So, if you send a file to printer A, an "lpd" will start for printer A.
- If you then send a file to printer B, if the "lpd" for printer A is done,
- an "lpd" for printer B will start. But if the "lpd" for printer A is not
- done, the new "lpd" for printer B will exit, the "lpd" for printer A will
- find a new file in it's spool directory and print it, on printer A, with no
- idea it was really sent to printer B.
-
- There's a way to kludge around this problem using two spool directories with
- one lock file, but that gets into other problems I won't try to explain.
- (like above, printer B still exits, but then printer A needs to start
- printer B when it's done).
-
- The best way to deal with this problem is to either use the built-in lpr/lpd
- flags, or perhaps have some auto-switching program as ":if=" that looks at
- the file and runs different filters depending on the input. Perhaps using
- different commands that users call instead of different printer names
- (ie instead of "lpr -P text" & "lpr -P ps" use "lprtext" and "lprps" that
- do the right thing internally).
-
- --
- Bill Stapleton
- wls@csd4.csd.uwm.edu
- uwmcsd4!wls
-