[cups.general] add header to print jobs

Johannes Meixner jsmeix at suse.de
Wed Dec 21 07:40:50 PST 2011


Hello,

On Dec 21 05:14 Vincent R. wrote (excerpt):
> > I am facing a problem that is: we send print jobs
> > to a print server which handle the layouts to use
> > based on the print queue sent.
> >
> > for example : we send a print job from a third party
> > software. CUPS should then add an header of 10 lines
> > containing on first line the print queue + the printjob-ID.
> > the 9 remaining lines should contain a 0 (zero) as first
> > character. based on this the print server knows what
> > template to use.

This looks as if those print server is the place where
the data in the print job is converted into whatever kind
of printer specific data and finally those print server
sends the printer specific data to the printer device.

If my assumption is correct, this means that you do not want
that CUPS does - as usual - convert the data in the print job
into printer specific data. Instead CUPS should only add
those special header but leave the data in the print job
unchanged.

If my assumption is still correct, you do not need any of the
usual CUPS filtering. Instead using only a so called
"System V style interface script" in CUPS should do it.

Such a script could be /tmp/my_interface_script like:
-------------------------------------------------------------
#! /bin/bash
# debug info in /var/log/cups/error_log
set -x
# have the input at fd0 (stdin) in any case
[ -n "$6" ] && exec <"$6"
# send the header
# first the print queue plus job number
echo $PRINTER $1
# then 9 empty lines (i.e. 9 newline characters)
echo -en '\n\n\n\n\n\n\n\n\n'
# finally send the print job data
cat -
-------------------------------------------------------------

To set up a queue using this script use a command like:
# lpadmin -p queue -i /tmp/my_interface_script -v deviceURI -E

If you get a warning message from the cupsd like
"Directory /etc/cups/interfaces has insecure permissions"
you may use
# chown root:lp /etc/cups/interfaces
# chmod 755 /etc/cups/interfaces

When I print to a queue which uses this script e.g. via
---------------------------------------------------------
$ echo -e 'Hello\nworld' | lp -d myqueue
request id is myqueue-123
---------------------------------------------------------

I see in /var/log/cups/error_log something like
------------------------------------------------------------
[Job 123] Started filter /etc/cups/interfaces/myqueue
....
[Job 123] + '[' -n /var/spool/cups/d00123-001 ']'
[Job 123] + exec
[Job 123] + echo testy 123
[Job 123] + echo -en '\n\n\n\n\n\n\n\n\n'
[Job 123] + cat -
(/etc/cups/interfaces/myqueue) exited with no errors.
------------------------------------------------------------

and as printing result I get this:
-------------------------------------------------
myqueue 123









Hello
world
-------------------------------------------------


> I have no clue how the filters are working and also I don't know
> if I will be able to achieve my needs because it is very specific.
> basically we are migrating from Solaris to Suse linux. I see you
> are working for novell :-) we have support contracts with novell
> do you think I can also ask for some help by opening an SR ?

I am afraid, I do not work in a support department so that I do
not know about the details regarding support contracts.

I assume it depends on your particular support contract which
kind of issues are supported but I assume you could at least
ask for help. I assume the worst case could be that you are
informed that such kind of issues are not supported by your
current support contract but - as far as I know - we provide
(almost) any kind of support via various support contracts.


By the way:
Strictly speaking I am working for SUSE, see
http://www.suse.com/company/


Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH -- Maxfeldstrasse 5 -- 90409 Nuernberg -- Germany
HRB 16746 (AG Nuernberg) GF: Jeff Hawn, Jennifer Guild, Felix Imendoerffer





More information about the cups mailing list