[ Table Of Contents ][ Answer Guy Current Index ] greetings   bios   1   2   3   4   5   6   7   8   9   10   12   13   14   15   16   17   18   19   20 [ Index of Past Answers ]

(?) The Answer Gang (!)


By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and the Gang, the Editors of Linux Gazette... and You!
Send questions (or interesting answers) to tag@lists.linuxgazette.net

There is no guarantee that your questions here will ever be answered. You can be published anonymously - just let us know!


(?) Checks vs. Plain Paper

set your print queues to stun, er, hold.

From James McClure

Answered By Dan Wilder, Jim Dennis, Ben Okopnik, Heather Stern, Mike Orr

I need to find a way to print to specific forms, such as checks, invoices, etc. Whenever my accounting people get ready to print out checks, it never fails that someone will send a print-job to the printer. It will then be printed on the checks instead of normal paper. Is there a way to accomplish this through LP... from what I've tried, read, and heard... I've had NO LUCK!

Any help is appreciated!

James McClure

(!) [Dan] You did not mention what operating system you're using.

(?) Apologies... I'm running RedHat 6.1 (Kernel 2.2) with LPD.

James

There's at least 4 types of possibile answer...
0. Have a seperate printer, then you don't need this question.

(!)[Ben] The "real" solution is to have a separate check printer; anything less is going to require juggling, and anything we can suggest here that's short of that is going to be painful in some way. <shrug> That's Life with Band-Aids for you.
(!) [Dan] In the Bad Old Days of twenty different pre-printed forms on the shelf, everybody's mini-mainframe had forms management built in to the OS. It didn't seem so awful to us then. It certainly beat spending umpteen thousands of dollars a month to lease twenty different printers, most of them seldom used, from IBM. Not to mention the impact of the 3' by 4' by 4' form factor!
If you were printing more than one pre-printed form, say, checks drawn against five different accounts, each once a month, having five dedicated printers sitting idle most of the time, and a sixth for everyday use, would seem maybe just a little wastful of the equipment budget.

1. Construct a scripted front end to help you handle it:

(!) [Dan] This one begs for a forms management interface program. With a long-running interface program on the system console that would display, for example,
(!) [JimD] Yuck! A console requires babysitting.
(!) [Dan] The printer requires babysitting anyway. When you change forms. If the console's next to the printer, there's no additional work to speak of.
(!) [Dan] The application would be run as the login shell of a printer control user, who would normally be logged into some terminal near the printer. It would assume some default form at its startup time, and merrily release print jobs so long as they call for the available form, holding the print queue when the next job up calls for a form that is not currently inserted.
I'm unaware of anything quite so friendly for Linux forms handling. Instead, as you've observed, we have lpd.
Have you investigated using the lpc command for this? By doing
lpc
holdall laz
[ run the check job ]
lpq
[ lists print jobs held. Figure out which one is your check-printing batch. ]
release jobid
[ releases the job with id "jobid" for printing ]
release laz
[ releases all remaining jobs, after special forms jobs are finished ]
You'd have to set up sudo to allow selected users to run lpc.

2. Try to use the queues feature built into lpr:

(!) [JimD] The classic approach to this problem is to create additional queues on that printer. When you mount a form on a given printer, you use your printer system's control utility (lpc under Linux) you stop printing of all queues, and enable printing of just the one that relates to the currently mounted form. After, you dismount the special paper (checks, pre-printed forms, etc) you stop the form queue and start the general queue(s).
(!) [Dan] ff printcap entry "check" has the autohold flag ":ah:" in it, so jobs sent to it are normally held. After running checks using
lpr -Pcheck
you'd use lpc:
lpc
holdall laz
[ wait until printing on "laz" stops, then change forms ]
release check
[ or 'lpq' then 'release jobid' ]
[ wait until check printing stops ]
holdall check
release laz
This saves having to guess which jobs are checks.
(!) [JimD] Note that you can stop printing of a queue without disabling submissions to it. Thus your other printing traffic will continue to queue up while the special forms are loaded. When you reload the normal paper, the other jobs will all get printed as normal.
(!) [Dan] With the ":ah:" flag, you might not need to "holdall check" at the end; I'm not sure whether "release check" applies only to jobs currently in the spool, or to future jobs also.
(!) [JimD] This is the whole reason why the BSD lpd supports multiple queues connected to any printer. It gives you some administrative flexibility. You can use it to support forms and special papers (colors, sizes, etc). You can also use it to (very roughly) manage priorities (so you time critical monthly, quarterly, or annual accounting jobs can be give abolute priority over other printing traffic for a few days, for example).
Of course you can use lpc in shell scripts to automate the work of stopping and starting specific queues.
(!) [Dan] Note the (admittedly confusing) lpr man page calls a printcap queue (declared with -P) a printer.
(!) [Heather] Think "virtual printer" if it works better for you...
(!) [JimD] None of this is as easy as we'd like. There are commercial packages which purport to offer "friendlier" and "easier" interfaces to printer management under Linux. I've never used any of them, nor have I played with CUPS or recent versions of LPRng. I've just managed to get by using the plain old BSD lpd, so far.
(!) [Mike] Have you been able to do this without getting "cannot open /dev/lp0" errors? (I don't remember the exact error message.) I have two printers, HP LJ 4L and Epson Stylus Color 600, which I switch back and forth on the parallel port. Sometimes I have to bring down the LPD daemon entirely (or sometimes even reboot) in order to switch from one to the other.
(!)[Dan] The topic was multiple virtual printers on the same physical device. It sounds like you're asking about multiple physical printers on the same hardware port.
(!)[Mike] He and I both have two "drivers" (LPD stanzas) going to the same device. The difference is that he has one printer on the other side of the device, while I switch printers. But it's not switching printers that causes the "device in use" error; it also happens if I forget to switch the printers. Thus, why it could happen to Mr McClure too. Apparently LPD (from LPRng) doesn't close the device in a timely manner after finishing a print job, so that another driver can use the same device.
(!) [Dan] I can probably concoct at least three other ways to do it.
The disadvantage of "start check" is you must remember to "stop check" when you're done. By using the ":ah:" flag you _might_ not have to remember one more step at the end.
Darned if I can see from the documentation what the functional difference between "stop printer" and "holdall printer" is. Both appear to allow queuing, while holding print. "holdall" doesn't appear to apply to current jobs, so the default non-check printer might finish printing more stuff after "holdall lp" (or whatever name is used for that printer) than "stop lp".
So maybe the perfect sub-optimal solution is:
lpc
stop lp
[ wait for current job to finish ]
[ insert check forms ]
start check
[ wait for checks to print ]
stop check
start lp
quit
or a setuid CGI that issues equivalent commands.
(!) [Ben] <gag><choke><choke><gasp>
(!) [JimD] Something more friendly than this could be cooked up as a simple set of shell scripts that were activated by CGI/PHP web forms.
(!)[Heather] There's a CGI front-end for LPRng called LPInfo.
(!)[Dan] But, I don't much like setuid CGIs.
(!)[Ben] <understatement value="annual"> Gee, me either. </understatement>
I'd probably try the first solution suggested above, then set up some scripting stuff to save steps once the "easiest" procedure has been finalized. The "real" solution is to have a separate check printer; anything less is going to require juggling, and anything we can suggest here that's short of that is going to be painful in some way. <shrug> That's Life with Band-Aids for you.
(!) [Dan] In the Bad Old Days of twenty different pre-printed forms on the shelf, everybody's mini-mainframe had forms management built in to the OS. It didn't seem so awful to us then. It certainly beat spending umpteen thousands of dollars a month to lease twenty different printers, most of them seldom used, from IBM. Not to mention the impact of the 3' by 4' by 4' form factor!
If you were printing more than one pre-printed form, say, checks drawn against five different accounts, each once a month, having five dedicated printers sitting idle most of the time, and a sixth for everyday use, would seem maybe just a little wastful of the equipment budget.
(!)[Dan] I still think the optimal solution is a forms control app run as the login shell of a printer control user.
But then, I always put a monitor someplace near each printer. Often a plain old text console.

3. Or you can see if one of the new printing systems makes it easier than we described here:

(!)[JimD] However, it's definitely worth looking at the alternatives, so I'll list a couple of URLs that relate to printing under Linux (most of which will also be relevant to any other form of UNIX):
The Linux Printing HOWTO
http://www.linuxdoc.org/HOWTO/Printing-HOWTO/index.html
This has a section on spooling software which, naturally enough, includes links to the major free spooling packages.
The Linux Printing Usage HOWTO
http://www.linuxdoc.org/HOWTO/Printing-Usage-HOWTO.html
(!)[Heather] This one's dusty and has some things just plain wrong (the PDF stuff, for example; xpdf is not an Adobe product at all) but it has an okay introduction to the bare lpr commands, if you have to go there. With any of the front-end systems below for printing, you might not need it:
The LPRng HOWTO:
http://www.astart.com/lprng/LPRng-HOWTO.html
Hey, check it out, you can specify job classes, so you could actually tell the single printer that it only has plain paper in it right now, so hold all jobs that are of the check class. I'm sure this can easily be extended to letterhead or other special forms. The tricky part is to have your check runs properly register that they are of the "check" class so this would work.
(!)
[Mike] CUPS: the Common Unix Printing System
http://www.cups.org
PDQ: Print, Don't Queue
http://pdq.sourceforge.net
Links to these and more on the Linux Printing site.
http://www.linuxprinting.org

(!) Thanks for your help!

James

(!) [Ben] Hope it does some good.
(!) [Heather] You're welcome, from all of us!


This page edited and maintained by the Editors of Linux Gazette Copyright © 2001
Published in issue 67 of Linux Gazette June 2001
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/


[ Table Of Contents ][ Answer Guy Current Index ] greetings   bios   1   2   3   4   5   6   7   8   9   10   12   13   14   15   16   17   18   19   20 [ Index of Past Answers ]