Operating System - HP-UX
1832490 Members
3028 Online
110043 Solutions
New Discussion

Redirect print requests from 1 printer to another

 
bhoang
Advisor

Redirect print requests from 1 printer to another

Wonder if there is a print command to automatically redirect the print requests from the bad printer to another one? I use lpmove, but that only applies to that instance.
TIA
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: Redirect print requests from 1 printer to another

The closest approach using standard lp commands is to create a class of printer. The individual members of a class do not all have to be identical printers.

Let's say that we have three printer p1, p2, and p3 and we want to create a new class, class1.

lpadmin -p p1 -c class1 # if the class does already exist, it is created
lpadmin -p p2 -c class1 # add p2 to the class
lpadmin -p p3 -c class1 # add p3 to the class

accept class1

lp -dclass1 myfile

Now, when you use a class the first available printer will be used. If a member of a class is disabled, the jobs are automatically sent to the remaining functional members of the class.

Note: You can still specify a printer for a particular job even if that printer is also a member of a class but in that case there would be no automatic failover.
If it ain't broke, I can fix that.
bhoang
Advisor

Re: Redirect print requests from 1 printer to another

The bad printer is hardcoded in quite a few programs... Wonder if I can use a command to temporarily redirect all print requests from the bad printer to a good one w/o going tru changing the programs?
A. Clay Stephenson
Acclaimed Contributor

Re: Redirect print requests from 1 printer to another

Well, if developers hard-coded anything like a printer name into an application I would hard-code them with a baseball bat.

The obvious solution (after you have applied the baseball bat for future reference) is to remove the hard-coded printer from lp and add the printer back with another name. Next you create a new class with the name of your hard-coded printer and put as many printers into the class as you wish. Now the applications won't have a clue that they are really printing to a class rather than a printer.
If it ain't broke, I can fix that.
Jonathan Fife
Honored Contributor

Re: Redirect print requests from 1 printer to another

If they are both network printers you could change the PERIPH line in the /var/spool/lp/interface/ file to point to the hostname/IP of the good printer.

Decay is inherent in all compounded things. Strive on with diligence
bhoang
Advisor

Re: Redirect print requests from 1 printer to another

Thanks for the input!
A. Clay Stephenson
Acclaimed Contributor

Re: Redirect print requests from 1 printer to another

Changing the PERIPH line only works if the model scripts are compatible; the class solution is much more elegant.
If it ain't broke, I can fix that.
bhoang
Advisor

Re: Redirect print requests from 1 printer to another

Thank you all!