Operating System - HP-UX
1823058 Members
3178 Online
109645 Solutions
New Discussion юеВ

print duplicate in two printers

 
SOLVED
Go to solution
Grace Li
Frequent Advisor

print duplicate in two printers

is it possible in unix to send print job to a device and two printers will print the job at the same time?
I have an application to print a ticket to one printer in Toronto office. However, we need to get the same ticket printed in Vancouver office at the same time. Note this is real-time generated ticket, which can NOT be reproduce. Otherwise, the application will enter the order again.
17 REPLIES 17
TTr
Honored Contributor

Re: print duplicate in two printers

Can you check if this can be done within the application? Is some apps you have to actually put in an lp command in an app config file of setup screen. See if you can put in a compound UNIX command with two lp commands and two UNIX spoolers.
Grace Li
Frequent Advisor

Re: print duplicate in two printers

Unfortunately, I don't have the control to this application (like, source code). Is there a way to deal with with it from Unix System level?
Paul Sperry
Honored Contributor

Re: print duplicate in two printers

banner test | lp -ditcolor | lp -dhelp_desk_lj0



this sent the test banner to both printers itcolor and helpdesk_lj0
Grace Li
Frequent Advisor

Re: print duplicate in two printers

Thanks Paul. How can I turn on this print feature? so that HP-UX knows there is a job printing in "itcolor" and then triggers this command.
Paul Sperry
Honored Contributor

Re: print duplicate in two printers

Actually that didn't work it printed the banner on the first printer and just the request id message on the second printer.

Sorry but the second printer is further from my desk
Paul Sperry
Honored Contributor

Re: print duplicate in two printers

Take a look at intelliscribe broadcast printing


http://lpr.brooksnet.com/broadcast-printing.html
Paul Sperry
Honored Contributor

Re: print duplicate in two printers

Paul Sperry
Honored Contributor

Re: print duplicate in two printers

probably not what you looking for but who knows. The following does work though.


for x in printer1 printer2
do
lp -d$x afile
done

And another way is to create a class

lpadmin -pprinter1 -cq1
lpadmin -pprinter2 -cq1

lp -dq1 -n2 afile
That would create and enable the class Q1 and assign printers P1 and
P2 to it. When a job is sent to a class, it prints on whichever
printer in the class becomes available first. If my guess is right,
using "-n 2" (which requests two copies) will cause one copy to come
out on each printer. Actually, it will only do this if both printers
are idle; otherwise, both copies may come out on the same printer.

Paul Sperry
Honored Contributor

Re: print duplicate in two printers

Another thought. Make a new lp

for x in printer1 printer2; do /usr/bin/lp -d$x $*;done

#chmod 755 lp
#export PAHT=$PATH:/path/to/new/pl
make sure your using the right lp
#/usr/bin/whitch lp
/home/user/bin/lp

#lp afile

sends the file to both printers
Grace Li
Frequent Advisor

Re: print duplicate in two printers

Thanks Paul. Let try run some tests.
Tim Nelson
Honored Contributor
Solution

Re: print duplicate in two printers

Here is one that works.

Edit the /etc/lp/interface/ file for printer1. Add this "cat $6|lp -dprinter2" towards the top, somewhere after the export $PATH.

Works like a charm.

All jobs sent to printer1 will also be sent to printer2

substitute the names as you wish.

Grace Li
Frequent Advisor

Re: print duplicate in two printers

works! Thank you.
Grace Li
Frequent Advisor

Re: print duplicate in two printers

Thanks Tim! adding that line works, what does "$6" stand for?
note that i have nobanner option on the lp command, but the duplicate still has the banner on. is there a way to fix it?
Dennis Handly
Acclaimed Contributor

Re: print duplicate in two printers

>what does "$6" stand for?

The sixth parm to /etc/lp/interface/printer1.
But scanning /usr/lib/lp/model/*, I don't see it used in any scripts that isn't dead code.

>i have nobanner option on the lp command, but the duplicate still has the banner on.

You will have to "copy" the parms to the interface file and convert them back to lp options to pass to ... |lp -dprinter2

Either you always add -onb. Or you look at the parms and add it.
What does your interface script look like?
(Please attach.)
Grace Li
Frequent Advisor

Re: print duplicate in two printers

Here comes the file.
Dennis Handly
Acclaimed Contributor

Re: print duplicate in two printers

>what does "$6" stand for?

This is the first file to be printed. If you print more than one at the same time, you would only duplicate the first.

>i have nobanner option on the lp command, but the duplicate still has the banner on.

Is this -onb? It would be trivial to always set it. But if you want this conditioned by the original value, I would need to see some debugging output.

Remove this cat below:
cat $6|lp -dvanapps ### added
# Add bin to the path for systems with /bin

...
done
# Insert this comment and lp here:
# Duplicate each file on vanapps
lp -dvanapps $files
if [ "$debugf" != "" ]
...

If you just want to add -onb above you could use:
# Duplicate each file on vanapps
lp -dvanapps -onb $files

If you want to condition -onb, then we need to print the options. Add this before that lp.

LOG_options=/tmp/model_options.log
echo "LP options for: $file1: $options" >> $LOG_options
Tim Nelson
Honored Contributor

Re: print duplicate in two printers

>>Thanks Tim! adding that line works, what does "$6" stand for?
note that i have nobanner option on the lp command, but the duplicate still has the banner on. is there a way to fix it?

$6 is the 6th arg that lp is passing to the interface file which happens to be the temp name of the file that is being printed.

As far as getting rid of the banner just modify the line you added "cat $6|lp -dPrinter2 -o nb" and/or any other options you like. This could certainly be made more eloquent byt parsing all the command line options but sometimes simplicity has is virtues at the cost of being flexible.