backend script standard

Binh Nguyen binh25 at gmail.com
Mon Oct 9 19:31:43 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/
>

Thankyou all for your input I got my script to finally work with cups backend and this is the information I'm looking for :). I didnt know it's expecting a six arg

if [ -n "$6" ]
 then
   exec <"$6"
fi




More information about the cups mailing list