1829894 Members
2464 Online
109993 Solutions
New Discussion

cups queue issue

 
SOLVED
Go to solution
Unix Administrator_5
Frequent Advisor

cups queue issue

I need to come up with a mechanism for setting up a print queue that will accept a job and send it to two different printers at the same time.

Is this possible?

I am using RHEL 3.0 ES
10 REPLIES 10
Bojan Nemec
Honored Contributor

Re: cups queue issue

Hi,

One possible solution is to create a script like this:

#!/bin/bash
cat > /tmp/printjob.$$
lpr -P printer1 /tmp/printjob.$$
lpr -P printer2 /tmp/printjob.$$
rm /tmp/printjob.$$

then create an entry in the /etc/services:

dualprinter 9101/tcp
(replace 9101 with a port you want)

then create in /etc/xinet.d the dualprinter description:

service dualprinter
{
disable = no
socket_type = stream
wait = no
# choose a user to run
user = USER
# replace with the path to the previous script
server = PATH_TO_SCRIPT
log_on_failure += USERID
log_on_success += USERID
}

Now configure a new queue as a jetdirect queue on localhost ip address and the port you have choosen. You can use this also from other systems (linux and non linux).

Bojan
Bojan Nemec
Honored Contributor

Re: cups queue issue

Sorry I forgot,

You must restart xinetd to start the service:
service xinetd restart

Bojan
Unix Administrator_5
Frequent Advisor

Re: cups queue issue

I am not sure I am following what this is doing. Could you explain it a bit more for me?
Bojan Nemec
Honored Contributor

Re: cups queue issue

I will try to explain.

xinetd is a server program which waits on the configured ports. When a connection is made to a specific port forks and runs the specified program (or script) substituting its stdin and stdout with the socket.
The entry in /etc/services and the file in /etc/xinet.d are need to instruct the xinetd to wait on the specified port.

The so called jetdirect mode of printing is nothing other than a raw tcpip socket. When you have a printer server or a network enabled printer printing consist in formating data for the printer and sending this data to this socket. If you have such a printer you can try with: telnet PRINTER_ADDRESS PORT where PRINTER_ADDRESS is the printer TCPIP host name or address and PORT is the port number (in most cases 9100) then type something and terminate with (form feed) to eject the page. You will see that the printer will print that you have typed. (use and quit to exit from telnet).

When you enable the service you create a listening port on yours machine (You can try the previous telnet with telnet localhost 9101).

The script does nothing other than copy the whole print job in a temporary file on the tmp directory (/tmp/printjob.$$ where $$ is the pid of the current job).
When this file is saved it is printed to printer1 and printer2.
You should configure each printer in cups and substitute printer1 and printer2 in the script with the names of yours real queues. You should also configure one queue which will print to the virtual printer.

One drawback is that the printers must be of same type.

As I say this is one possible solution. Maybe someone other will give you a better solution.

Bojan
Unix Administrator_5
Frequent Advisor

Re: cups queue issue

Seems like a creative way to attack this problem; however, I have to have something that doe the following

lp -dprinter file_to_print

This must go to two different printers at the same time. Unfortunately the application uses that mechanism.

I am not sure I'll be able to use you suggestion with this constraint.

However, I very much appreciate this.
Bojan Nemec
Honored Contributor
Solution

Re: cups queue issue

More explanations:

First
You have to create 2 queues in cups. One for each physical printer. Say that the names are printer1 and printer2.

Now you can print to the printers with:

lp -dprinter1 file_to_print
lp -dprinter2 file_to_print

Second
You create the xinetd service which will act as a printer (cups will not notice that this is not a physical printer). And you create a queue in that points to this virtual printer say that the name is printer as you mentioned.

Now when you print to this printer with:

lp -dprinter file_to_print

cups will transfer the file to the script which can be (to be more explanatory):

cat > file_to_print
lp -dprinter1 file_to_print
lp -dprinter2 file_to_print


In my script I substituted file_to_print with /tmp/printjob.$$ to have a unique name.

Bojan
Unix Administrator_5
Frequent Advisor

Re: cups queue issue

thanks, i'm gonna give this a try and post the results.
Ivan Ferreira
Honored Contributor

Re: cups queue issue

I think that the easy way is to use printer classes. Use your web browser and in the Linux Server connect to localhost:361. You will get the cups administration web page. See the online documentation for further reference about printer classes.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Unix Administrator_5
Frequent Advisor

Re: cups queue issue

I was under the impression that printer classes still only printed to one printer
Bojan Nemec
Honored Contributor

Re: cups queue issue

My impression was the same so I checked. On my home system RedHat 9.0 the job is printed only on one printer (tested with two virtual printers which copy the contents to a temporary file).

Within this testing I have a ne Idea abbout the virtual printer. Configure the printer as a postscript/Generic postcript printer. This will translate the printing job in post script and the two other printers will receive postscript data as input. So the printers can be of different type and cups will translate postscript to the right printer language which depends on the printer.

Bojan