lpadmin(8) question

Bill Irwin bill at twg.bc.ca
Sat Jun 2 20:19:42 AEST 1990


In article <453 at van-bc.UUCP> sl at van-bc.UUCP (Stuart Lynne) writes:
>Which is what I need to do. I have two different packages that want to
>install specialized lp destinations with appropriate filters. Can I install
>both and have lp figure out how multiplex the requests for the two
>destinations to the one physical printer?
>
>Or will I have to hack the two interfaces together and add options?
>
>What I wanted was for file1 to be printed, followed by file2. What I got was
>file1 intermingled with file2 being printed.

I  have had this same problem.  I have one printer that is used for  four
lp destinations.  When jobs are queued to two or more of the destinations
at  the  same time, you get garbage.  The solution I came up  with  works
very  well.  It involves adding some lines to the models which will check
to  see if there is a lock file in place for this physical printer,  wait
if  there is;  make a lock file if there isn't;  print the job(s);   then
remove the lock.  I have attached excerpts from one of my models.


:       computer_pr
#       Looks for print jobs on any printer on the same port as
#       computer_pr, and waits until there are no jobs before
#       continuing.
#
if [ -f /tmp/computer.lock ]
then
        while [ -f /tmp/computer.lock ]
        do
                sleep 60
        done
fi
touch /tmp/computer.lock
#
#       Copyright (C) The Santa Cruz Operation, 1985, 1986.
#       This Module contains Proprietary Information of
#       The Santa Cruz Operation, Microsoft Corporation
#       and AT&T, and should be treated as Confidential.
#
#!      computer_pr
#       Options: lp -ob   no banner
#
.   [rest of the standard model here]
.
.
# send the file(s) to the standard out $copies times
while   [ "$copies" -gt 0 ]
do
        for file
        do
                echo -n " 0  6 F66"       # Oki 32x codes
                cat "$file" 2>&1
                echo "\f\c"
                echo -n " 0  6 F66"       # Oki 32x codes
        done
        copies=`expr $copies - 1`
done
rm /tmp/computer.lock
stty -hupcl 0<&1
exit 0


The  only drawback with this approach that I have encountered is when you
cancel  a print job the lock is not removed.  You have to remember to "rm
/tmp/computer.lock" after your cancel, otherwise you next jobs will never
print.

I  remember  trying to solve this once by trapping the rm  lock  sequence
inside the model, but it didn't work.  I would be interested in finding a
better  solution  than this which doesn't force the user to  remember  to
remove a dead lock file.

Good luck.
-- 
Bill Irwin - TWG The Westrheim Group - Vancouver, BC, Canada
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uunet!van-bc!twg!bill     (604) 431-9600 (voice) |     UNIX Systems
Bill.Irwin at twg.bc.ca      (604) 431-4629 (fax)   |     Integration



More information about the Comp.unix.wizards mailing list