[cups.general] backend script standard

Johannes Meixner jsmeix at suse.de
Mon Oct 9 05:21:51 PDT 2006


Hello,

On Oct 9 06:51 Binh Nguyen wrote (shortened):
> Does anyone have an example of a shell script that conform to
> cups backend standard?

Here a very simple example for a selfmade "lp0" backend
for the parallel port whith everything hardcoded in the backend
and a possible (but unlikely) race condition:
----------------------------------------------------------------------
#! /bin/bash

# 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
----------------------------------------------------------------------
Place it in the directory where the other backends are
with same owner, group and permissions as the other backends.
Restart cupsd and verify with "lpinfo -v" that the cupsd has
recognized the new backend.

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