Samba PDF Printer Problem - SMB

This is a discussion on Samba PDF Printer Problem - SMB ; I've got a samba PDF printer setup on one of my servers and it's been running fine for a couple of months now (windoze & linux clients), but suddenly today it stopped working. Very strange, especially as the shares on ...

+ Reply to Thread
Results 1 to 16 of 16

Thread: Samba PDF Printer Problem

  1. Samba PDF Printer Problem

    I've got a samba PDF printer setup on one of my servers and it's been
    running fine for a couple of months now (windoze & linux clients), but
    suddenly today it stopped working.

    Very strange, especially as the shares on the same box still worked. I
    tried printing from localhost but no joy.

    I tried restarting samba, no joy, in desperation I tried rebooting the
    server, still no joy.

    Last thing I've tried is setting up a new printer exactly the same but
    with a different name, and that works!

    Can anyone tell me why samba might start refusing connection to an
    existing printer share? And more importantly how to fix the problem.

    I really need to find a fix to this otherwise I'll be changing printer
    settings on all 200 PCs in the office and I don't want to be doing that!

    -- Nick Gushlow.

  2. Re: Samba PDF Printer Problem

    On Wed, 20 Oct 2004 18:51:26 +0100, Nick Gushlow wrote:

    > Can anyone tell me why samba might start refusing connection to an
    > existing printer share? And more importantly how to fix the problem.
    >
    > I really need to find a fix to this otherwise I'll be changing printer
    > settings on all 200 PCs in the office and I don't want to be doing that!


    I experienced a similar problem yesterday and it turned out to be a
    corrupted cache file.
    After trawling through logs trying to get a clue what had broken, I saw
    an obscure error message referring to a cache file. I just deleted the
    ..tdb file for the printer in question and it started working again.

    In RH/Fedora the files are located in "/var/cache/samba/printing/",
    it might be slightly different in other distros.

    Your problem might be something completely unrelated, but it's worth
    looking at.




  3. Re: Samba PDF Printer Problem

    On Wed, 20 Oct 2004 19:04:43 +0000, Gary Beldon wrote:

    > I experienced a similar problem yesterday and it turned out to be a
    > corrupted cache file.
    > After trawling through logs trying to get a clue what had broken, I saw an
    > obscure error message referring to a cache file. I just deleted the .tdb
    > file for the printer in question and it started working again.
    >
    > In RH/Fedora the files are located in "/var/cache/samba/printing/", it
    > might be slightly different in other distros.
    >
    > Your problem might be something completely unrelated, but it's worth
    > looking at.


    That did the trick, thanks. :-)

    -- Nick.

  4. Re: Samba PDF Printer Problem

    On 10/20/2004 1:51 PM, I believe that Nick Gushlow wrote:

    > I've got a samba PDF printer setup on one of my servers and it's been
    > running fine for a couple of months now (windoze & linux clients), but
    > suddenly today it stopped working.
    >
    > Very strange, especially as the shares on the same box still worked. I
    > tried printing from localhost but no joy.
    >
    > I tried restarting samba, no joy, in desperation I tried rebooting the
    > server, still no joy.
    >
    > Last thing I've tried is setting up a new printer exactly the same but
    > with a different name, and that works!
    >
    > Can anyone tell me why samba might start refusing connection to an
    > existing printer share? And more importantly how to fix the problem.
    >
    > I really need to find a fix to this otherwise I'll be changing printer
    > settings on all 200 PCs in the office and I don't want to be doing that!
    >


    How do you have your PDF printer configured?
    I have a PDF printer, but it creates a filename based on date, and does
    not include any user-identifiable information. I'd LIKE to be able to
    create a PDF file with a specified filename strored on a specified
    network share, but don't know how feasible that is...

    Tim

  5. Re: Samba PDF Printer Problem

    On Thu, 21 Oct 2004 09:10:13 -0400, tim wunder wrote:

    > I have a PDF printer, but it creates a filename based on date, and does
    > not include any user-identifiable information. I'd LIKE to be able to
    > create a PDF file with a specified filename strored on a specified
    > network share, but don't know how feasible that is...


    how are you calling print2pdf? directly? You might want to write a shell
    script wrapper to move the pdf file after its creation and rename it.

    --
    BOFH Excuse #353:

    Second-system effect.


  6. Re: Samba PDF Printer Problem

    On 10/21/2004 11:34 AM, I believe that Geoffrey King wrote:

    > On Thu, 21 Oct 2004 09:10:13 -0400, tim wunder wrote:
    >
    >
    >>I have a PDF printer, but it creates a filename based on date, and does
    >>not include any user-identifiable information. I'd LIKE to be able to
    >>create a PDF file with a specified filename strored on a specified
    >>network share, but don't know how feasible that is...

    >
    >
    > how are you calling print2pdf? directly? You might want to write a shell
    > script wrapper to move the pdf file after its creation and rename it.
    >


    I have a simple shell script that does the renaming and moving, but I
    don't know how to get user-specified information to use.

    The techniquie I'm using can be found here:
    http://www.linux-sxs.org/networking/...ing_Samba.html

    the script I'm using is basically this:

    #!/bin/bash

    #Convert postscript file into a PDF document
    # (c) John Bright, 2001, jbright@winfordeng.com

    DATE=`date +%b%d-%H%M%S`

    OUTDIR=/shr/pdfdropbox

    /usr/bin/ps2pdf $1 $OUTDIR/$DATE.temp
    mv $OUTDIR/$DATE.temp $OUTDIR/$DATE.pdf
    rm $1


    Is there a way to configure it so that the user supplies the filename to
    use? I'm far from a scripting expert...

    Thanks,
    Tim

  7. Re: Samba PDF Printer Problem

    tim wunder wrote:

    > Is there a way to configure it so that the user supplies the filename to
    > use? I'm far from a scripting expert...


    There are ways, but possibly not popular ways to do this. One that I
    have used for years with a print-to-fax script wot I have wrote is to
    scan the spooled Postscript looking for somethign that looks like a fax
    number. Then to strip out the number to be used for dialling.

    This requires each user to use a standard cover sheet for faxes in which
    the fax number is appropriately delimited so that it's easy to spot
    using a smidgen of Perl.

    You could use something similar to extract the filename but it would
    again require the user to embed the filename into their source document
    somehow. If you were really finicky you could snip this out of the
    output stream from your Perl filter so that it did not appear in the
    final document.

    Some knowledge of Perl, PostScript and generally script muck-aboutery
    required.

    --
    Quanto e quel cane nella vetrina (arf, arf)
    Quello con coda scuotente
    Quanto e quel cane nella vetrina (arf, arf)
    Spero che il cane sia vendita

  8. Re: Samba PDF Printer Problem

    On 10/21/2004 12:57 PM, I believe that Steve Firth wrote:

    > tim wunder wrote:
    >
    >
    >>Is there a way to configure it so that the user supplies the filename to
    >>use? I'm far from a scripting expert...

    >
    >
    > There are ways, but possibly not popular ways to do this. One that I
    > have used for years with a print-to-fax script wot I have wrote is to
    > scan the spooled Postscript looking for somethign that looks like a fax
    > number. Then to strip out the number to be used for dialling.
    >
    > This requires each user to use a standard cover sheet for faxes in which
    > the fax number is appropriately delimited so that it's easy to spot
    > using a smidgen of Perl.
    >
    > You could use something similar to extract the filename but it would
    > again require the user to embed the filename into their source document
    > somehow. If you were really finicky you could snip this out of the
    > output stream from your Perl filter so that it did not appear in the
    > final document.
    >
    > Some knowledge of Perl, PostScript and generally script muck-aboutery
    > required.
    >


    OK... Now you have me thinking...Let's say the document is a customer
    quote, and is a Word document, with the quote number assigned to the
    quote included as a field in the document (and document template from
    which the document is created).
    So all I'd have to do is create a script that finds where this field is
    in the output stream and uses the content of that field as the filename
    for the PDF file. Is that, more or less, it?
    If so, where do I go about finding the general "script muck-aboutery"
    required to do this?

    Thanks,
    Tim

  9. Re: Samba PDF Printer Problem

    tim wunder wrote:

    > So all I'd have to do is create a script that finds where this field is
    > in the output stream and uses the content of that field as the filename
    > for the PDF file. Is that, more or less, it?


    Yes.

    > If so, where do I go about finding the general "script muck-aboutery"
    > required to do this?


    You make it up out of your own head.

    You need to create a perl filter for the input stream of text. Something
    that reads from STDIN. Then you simply do something on the lines of:

    $myfilename = "";

    while () {
    print $_;
    # The above is making a copy of the input file,
    # this temporary file is what you will later
    # write out to ghostscript to be munged into
    # a PDF.
    if ($myfilename = "") {
    # check to see if the filename is in the current in line
    # I use /\(fax number:\)/i to find the fax number. You will
    # have to construct a regexp to uniquely match the filename tags
    # that you decide to use.
    #
    # Then you will need to slice up $_ using s// to give just the
    # filename sans tags.
    #
    # eg if your tags are <-filename-> then s/<-// and s/->//
    # should leave just filename.
    $filename = $_;
    }
    }

    # OK, by now you should have a spooled file as
    # and you have the filename in $filename so you have all you need
    # and you should be able to invoke ghostscript using:

    system gs


    I hope that makes some sort of sense.

    --
    Quanto e quel cane nella vetrina (arf, arf)
    Quello con coda scuotente
    Quanto e quel cane nella vetrina (arf, arf)
    Spero che il cane sia vendita

  10. Re: Samba PDF Printer Problem

    On Thu, 21 Oct 2004 09:10:13 -0400, tim wunder wrote:

    > How do you have your PDF printer configured? I have a PDF printer, but it
    > creates a filename based on date, and does not include any
    > user-identifiable information. I'd LIKE to be able to create a PDF file
    > with a specified filename strored on a specified network share, but don't
    > know how feasible that is...
    >
    > Tim



    The trick I had to go with is using the computer/netbios name and making
    sure that all the users PCs were named after the users (took a few hours
    one evening of renaming pcs).

    here's the print line out of my smb.conf:

    /usr/local/bin/pdfprinting %s %p %M %m %U %I %a %j %R %u

    in my pdfprinting script I use the passed variables to rename the file and
    log data; those variables are:

    %s: filename
    %p: path of service (printer name in this case)
    %M: Client DNS Name
    %m: Client NetBIOS name
    %U: Requested username
    %I: Client IP
    %a: Client Architecture
    %j: Job (according to the samba manual but this doesn't work)
    %R: Protocol
    %u: unix current username

    HTH.

    -- Nick.



  11. Re: Samba PDF Printer Problem

    On 10/21/2004 4:07 PM, I believe that Steve Firth wrote:
    > tim wunder wrote:
    >
    >
    >>So all I'd have to do is create a script that finds where this field is
    >>in the output stream and uses the content of that field as the filename
    >>for the PDF file. Is that, more or less, it?

    >
    >
    > Yes.
    >
    >
    >>If so, where do I go about finding the general "script muck-aboutery"
    >>required to do this?

    >
    >
    > You make it up out of your own head.
    >


    heh... I was afraid of that...

    > You need to create a perl filter for the input stream of text. Something
    > that reads from STDIN. Then you simply do something on the lines of:
    >
    > $myfilename = "";
    >
    > while () {
    > print $_;
    > # The above is making a copy of the input file,
    > # this temporary file is what you will later
    > # write out to ghostscript to be munged into
    > # a PDF.
    > if ($myfilename = "") {
    > # check to see if the filename is in the current in line
    > # I use /\(fax number:\)/i to find the fax number. You will
    > # have to construct a regexp to uniquely match the filename tags
    > # that you decide to use.
    > #
    > # Then you will need to slice up $_ using s// to give just the
    > # filename sans tags.
    > #
    > # eg if your tags are <-filename-> then s/<-// and s/->//
    > # should leave just filename.
    > $filename = $_;
    > }
    > }
    >
    > # OK, by now you should have a spooled file as
    > # and you have the filename in $filename so you have all you need
    > # and you should be able to invoke ghostscript using:
    >
    > system gs
    >
    >
    > I hope that makes some sort of sense.
    >


    Yep. Thanks. Something to play with...

    Tim

  12. Re: Samba PDF Printer Problem

    On 10/22/2004 4:54 AM, I believe that Nick Gushlow wrote:

    > On Thu, 21 Oct 2004 09:10:13 -0400, tim wunder wrote:
    >
    >
    >>How do you have your PDF printer configured? I have a PDF printer, but it
    >>creates a filename based on date, and does not include any
    >>user-identifiable information. I'd LIKE to be able to create a PDF file
    >>with a specified filename strored on a specified network share, but don't
    >>know how feasible that is...
    >>
    >>Tim

    >
    >
    >
    > The trick I had to go with is using the computer/netbios name and making
    > sure that all the users PCs were named after the users (took a few hours
    > one evening of renaming pcs).
    >
    > here's the print line out of my smb.conf:
    >
    > /usr/local/bin/pdfprinting %s %p %M %m %U %I %a %j %R %u
    >
    > in my pdfprinting script I use the passed variables to rename the file and
    > log data; those variables are:
    >
    > %s: filename
    > %p: path of service (printer name in this case)
    > %M: Client DNS Name
    > %m: Client NetBIOS name
    > %U: Requested username
    > %I: Client IP
    > %a: Client Architecture
    > %j: Job (according to the samba manual but this doesn't work)
    > %R: Protocol
    > %u: unix current username
    >
    > HTH.
    >
    > -- Nick.
    >
    >


    Thanks. I think it helps. Just need some time to play with it...

    Regards,
    Tim

  13. Re: Samba PDF Printer Problem

    On Thu, 21 Oct 2004 12:04:00 -0400, tim wunder wrote:


    > I have a simple shell script that does the renaming and moving, but I
    > don't know how to get user-specified information to use.
    >
    > The techniquie I'm using can be found here:
    > http://www.linux-sxs.org/networking/...ing_Samba.html
    >
    > the script I'm using is basically this:
    >
    > #!/bin/bash
    >
    > #Convert postscript file into a PDF document
    > # (c) John Bright, 2001, jbright@winfordeng.com
    >
    > DATE=`date +%b%d-%H%M%S`
    >
    > OUTDIR=/shr/pdfdropbox
    >
    > /usr/bin/ps2pdf $1 $OUTDIR/$DATE.temp
    > mv $OUTDIR/$DATE.temp $OUTDIR/$DATE.pdf
    > rm $1
    >
    >
    > Is there a way to configure it so that the user supplies the filename to
    > use? I'm far from a scripting expert...


    No, but we can put the outputted pdf in a slightly more sensible place. If
    you look at the smb.conf man page there is a section on the print command
    directive. It explains all the possible variables we can use. %J does what
    you need. You will need to alter the print command line in your smb.conf
    so it reads:

    print command = /usr/bin/printpdf %s %J

    Thus when the script is called the $2 variable will contain the jobname
    sent from the client which is trying to print. Thus we can make a simple
    change to your script to account for this. I've kept the date in the
    filenames produced to cut down on clashes. One final thing to note, BEWARE
    CLIENTS SENDING STUPID JOBNAMES!!!

    #!/bin/bash

    #Convert postscript file into a PDF document
    # (c) John Bright, 2001, jbright@winfordeng.com

    DATE=`date +%b%d-%H%M%S`

    OUTDIR=/shr/pdfdropbox

    /usr/bin/ps2pdf $1 $OUTDIR/$2.$DATE.temp
    mv $OUTDIR/$2.$DATE.temp $OUTDIR/$2.$DATE.pdf
    rm $1

    Untested, but it should work.

    --
    PLUG IT IN!!!


  14. Re: Samba PDF Printer Problem

    On Fri, 22 Oct 2004 08:05:39 -0400, tim wunder wrote:

    >> %j: Job (according to the samba manual but this doesn't work)


    its %J not %j

    --
    "If that makes any sense to you, you have a big problem."
    -- C. Durance, Computer Science 234

  15. Re: Samba PDF Printer Problem

    tim wunder wrote:

    > Yep. Thanks. Something to play with...


    And of course s/filename/myfilename/g

    because I fouled up.

    --
    Quanto e quel cane nella vetrina (arf, arf)
    Quello con coda scuotente
    Quanto e quel cane nella vetrina (arf, arf)
    Spero che il cane sia vendita

  16. Re: Samba PDF Printer Problem

    On Fri, 22 Oct 2004 14:22:58 +0000, Geoffrey King wrote:

    > On Fri, 22 Oct 2004 08:05:39 -0400, tim wunder wrote:
    >
    >>> %j: Job (according to the samba manual but this doesn't work)

    >
    > its %J not %j



    DOH! I'll go change my script now, thanks. :-)

    -- Nick.

+ Reply to Thread