Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!unmvax!bbx!bbxsda!scott From: scott@bbxsda.UUCP (Scott Amspoker) Newsgroups: comp.unix.xenix Subject: Re: Printing directly to the printer. Keywords: Printer locking strategy, Xenix, lp. Message-ID: <625@bbxsda.UUCP> Date: 20 Feb 90 20:43:22 GMT References: <178@actsn.fay.ar.us> Reply-To: scott@bbxsda.UUCP (Scott Amspoker) Organization: Basis International, Albuquerque, NM Lines: 53 In article <178@actsn.fay.ar.us> david@actsn.fay.ar.us (David Summers) writes: >I have a question regarding the way the print spooler works on Xenix: >Mainly, I need to print directly to the printer (if nothing else is printing >to it at the time). Therefore, I need to find out the procedure for locking >the print spooler. You will have to modify the spooler interface scripts. These may be found in the directory '/usr/spool/lp/interface'. There is an interface script for each printer you have set up. The basic idea is to modify the script to create a lock file at the beginning and remove the lock file at the end. However, this is not quite as straight forward as it sounds. You must guarantee that a 'test-and-set' type of operation is performed without interruption. This can be accomplished with the following shell code: ---------------- # umask is used to force r--r--r-- permissions on the create umask 333 # must use sub-shell to redirect error message ( until >$LOCKFILE do : done ) 2>/dev/null; --------------- The above code will create a lock file with r--r--r-- permissions or loop until an existing lockfile is removed. In addition to the above code you will also need to place the following command immediately after it: trap "rm $LOCKFILE; exit 0" 0 15 2 9 This will cause the lockfile to be removed whenever the script terminates (either normally or by the 'cancel' command). >I asked this question a few months ago and got the response from several people >that there was no need to do what I was suggesting. I think that saving disk >space is an adequate need. Obviously these people have never tried to do printer output to pre-printed forms either. I called SCO once about the spooler lockfile problem and they couldn't imagine why I would ever try to write directly to the printer. I mentioned that it is diffcult for an operator to interact with a test pattern being printed on invoice forms when using a spooler. Their response was, "oh". -- Scott Amspoker Basis International, Albuquerque, NM (505) 345-5232 unmvax.cs.unm.edu!bbx!bbxsda!scott