[cups.general] Re: Re: modify print job name

Johannes Meixner jsmeix at suse.de
Fri Jul 14 05:36:55 PDT 2006


Hello,

On Jul 14 06:47 Antonis Tsolomitis wrote (shortened):
> "Error occurred while executing su -c "/bin/cat /var/spool/cups/d00689-001 | /usr/local/bin/test " lp"

Try if it works when you simply remove the
---------------------------------------------------------------
if ($> == 0)
{
    $cmdln = "su -c \"$cmdln \" lp";
}
---------------------------------------------------------------
stuff.

> One more problem. pipe just does a cat to the script.
> But the job name is lost.

See "man backend" how to get the job name.
You would have to modify the pipe backend to pass the job name.

> If I write a script according to "man backend", is it enough to put
> it in the right directory with proper permissions so that cups
> can use it after a restart?

Yes.
Be aware that your backend must provide discovery information
like in the pipe backend
------------------------------------------------------------------------
if (@ARGV == 0)
{
print "file $scheme \"Unknown\" \"Printing to any command via pipe\"\n";
exit 0;
}
------------------------------------------------------------------------
where $scheme must be the file-name of the backend.

Here a very simple example for a selfmade /usr/lib/cups/backend/lp0
for the parallel port whith everything hardcoded in the backend
and a possible (but unlikely) race condition:
----------------------------------------------------------------------
#! /bin/bash
# see the "CUPS Software Programmers Manual":
# "Writing Filters" and "Writing Backends"

# 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
----------------------------------------------------------------------


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