[cups.general] Virtual Printers
Johannes Meixner
jsmeix at suse.de
Thu Jul 14 02:39:57 PDT 2005
Hello,
On Jul 13 16:54 Anonymous wrote (shortened):
> Here is specifically what I want to do:
> create a print Q in CUPS that accepts jobs from remote windows clients,
> grabs the job input file pipes it to a shell script and once the shell
> script exits, the job is done.
I.e. this shell script acts exactly as a CUPS backend does.
All you have to do is to create your own backend
and set up the queue by using this backend.
Here a very simple example for a selfmade backend
(it has everything hardcoded and is not 100% safe against
race conditions but if used as CUPS backend the cupsd
would run it for one queue only once at a time):
--------------------------------------------------------------------
#! /bin/bash
# see the "CUPS Software Programmers Manual":
# "Writing Filters" and "Writing Backends"
# and see the man page "man backend".
# debug info in /var/log/cups/error_log
set -x
# output "Device Discovery" information on stdout
if [ "$#" -eq "0" ]
then
echo 'direct lp0:/dev/lp0 "Unknown" "lp0 Printer"'
exit 0
fi
# have the input at fd0 (stdin) in any case
if [ -n "$6" ]
then
exec <"$6"
fi
# infinite retries to access the device
until cat /dev/null >/dev/lp0
do
echo 'INFO: cannot access /dev/lp0 - retry in 30 seconds' 1>&2
sleep 30
done
echo 'INFO: sending the data to /dev/lp0' 1>&2
# forward the data from stdin to the device
if cat - >/dev/lp0
then
echo 'INFO:' 1>&2
exit 0
else
echo 'ERROR: failed to send the data to /dev/lp0' 1>&2
exit 1
fi
--------------------------------------------------------------------
Have it executable as /usr/lib/cups/backend/lp0
restart the cupsd so that it recognizes the new backend
(verify this with "lpinfo -v") and then create a queue using
lpadmin ... -v lp0:/dev/lp0
Kind Regards
Johannes Meixner
--
SUSE LINUX Products GmbH, Maxfeldstrasse 5 Mail: jsmeix at suse.de
90409 Nuernberg, Germany WWW: http://www.suse.de/
More information about the cups
mailing list