[Samba] 2.2.6 and printer questions

Eirik Thorsnes eirik.thorsnes at fys.uib.no
Mon Nov 11 17:52:01 GMT 2002


Thomas Bork wrote:

> Hallo Eirik Thorsnes,
>
> you wrote:
>
> >>>> Is it correct, that the automatic download of printer drivers is
> >>>> only possible for printers, which are associated with an printcap
> >>>> entry? When I'm uploading a postscript driver for a *virtuell*
> >>>> printer, which is not associated with an printcap entry and then
> >>>> making an automatic installation of the driver on w2k, the status
> >>>> of this printer is always "Failure". The definition in smb.conf
> is:
> >>
> >> No.  Any printer can have drivers associated with it.
> [...]
> > Of course, but since the lpq command for a virtual printer don't give
> > a successfull result - you get an error on the client for the status.
> > My solution here was to set a "special" lpq command for the virtual
> > printer, which always returned a successful result when asked.
>
> great! Could you post this to the list?
>
>
> tom
>
Here is my pdf-virtual-printer:
(see also the Mandrake example in the source)

smb.conf:
---------------
to-pdf]
  path = /var/spool/samba
  guest ok = No
  printable = Yes
  comment = PDF Generator. Saves PDF to your home on server
  lpq command = /usr/local/bin/smb-pdfprint status
  print command = /usr/local/bin/smb-pdfprint %s %u &&\
    echo "Please find your new pdf-file in your home-dir on server"\
    |smbclient -M %m -I %I -U admin
---------------

smb-pdfprint:
(relevant part)
---------------
if [ "$1" == "status" ]; then
    echo "Printer: PDF-generator bogus status"
    echo "Queue: no printable jobs in queue"
    echo "Server: no server active"
    echo "Filter_status: done"
    echo "Rank  Owner/ID             Class Job Files    Size Time"
    exit 0
fi
---------------
(see also attached smb-pdfprint)

Eirik


-- 
REAL Programmers never work 9 to 5.
If any REAL Programmers are around at 9 AM,
it's because they were up all night.
-------------- next part --------------
#!/bin/bash
if [ "$1" == "status" ]; then
    echo "Printer: PDF-generator bogus status"
    echo "Queue: no printable jobs in queue"
    echo "Server: no server active"
    echo "Filter_status: done"
    echo "Rank  Owner/ID             Class Job Files    Size Time"
    exit 0
fi
if [ "x$1" == "x" -o "x$2" == "x" ]; then
   echo "$0: Not enough arguments."
   echo "Usage: $0 <filename> <username>"
   logger "$0: Wrong usage, exiting"
   exit 1 
fi
if [ "$2" == "root" -o "$2" == "daemon" -o "$2" == "apache" -o "$2" == "postgres" -o "$2" == "named" -o "$2" == "operator" -o "$2" == "bin" ]; then
   echo "$0: system accounts not allowed, exiting"
   logger "$0: system accounts not allowed, exiting"
   exit 1
fi
NEWFILE=`mktemp /var/spool/samba/pdfprint-${2}-XXXXXX`
if [ $? -ne 0 ]; then
  echo "$0: Can't create temp file, exiting..."
  logger "$0: Can't create temp file, exiting."
  exit 1
fi
ps2pdf13 -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode $1 $NEWFILE 
if [ -e $NEWFILE ]; then
MYHOME=`grep $2 /etc/passwd |awk -F: '{ print $6 }' - `
MOVEDFILE="$MYHOME/$(basename $NEWFILE).pdf"
  if [ -r $NEWFILE ]; then
     mv $NEWFILE $MOVEDFILE
  fi
  if [ $? -ne 0 ]; then
    echo "$0: Can't move temp file $NEWFILE to $MOVEDFILE, exiting..."
    logger "$0: Can't move temp file $NEWFILE to $MOVEDFILE, exiting."
    rm -f $NEWFILE
    exit 1
  fi
fi


More information about the samba mailing list