[Samba] I've always HATED printing with Samba
Joel Hammer
Joel at HammersHome.com
Wed Jul 23 02:23:04 GMT 2003
OK. Here is what works for me. As usual, your mileage may vary.
I assume you have installed the software for the lexmarkz53 on your
linux server. I assume you can print a test page. If you can't, likely
you are not printing the testpage to a raw queue. The testpage goes to a
raw queue while the real print jobs go to a filtered queue, in my setup.
I assume you know how to run the lexmark setup program which generates the
configuration file.
lexmark supplies print filters that work fine in linux to drive the z53.
I wrote a tutorial on print filters some time ago. I used this filter
as part of that writeup. Here is part of that tutorial.
============Start Tutorial=====================
There is a shell script called z53.sh. This is what your printcap file
should be pointing to.
/usr/local/lexmark/z53/z53.sh
This print filter accepts either pdf files, text files, or postscript files.
Then, using ghostscript, it converts them into a ppm format (whatever that
is), then it pipes them to the real filter, which only can come from
lexmark, z53, and then to your printer.
Here is the z53.sh script:
2 #!/bin/bash
3 DEBUG=0
4 PDIR=/usr/local/lexmark/z53
5 TMPFILE=`mktemp /tmp/lexmark.XXXXXX`
6
7 # lxgps is a little utility used to setup the
8 # Ghostscript parameters. It sets two parameters
9 # in particular: resolution and paper size. It
10 # determines what to set these to by reading the
11 # configuration file that is passed in.
12 GSPARMS=`$PDIR/lxacgsparm z53.conf`
13
14 runz53 ()
15 {
16 cat > $TMPFILE
17 file -b $TMPFILE | grep -i postscript > /dev/null
18 if [ $? -eq 0 ]
19 gs -q -dNOPAUSE $GSPARMS -sDEVICE=ppmraw
-sOutputFile=- $TMPFILE | $PDIR/z53 --config
z53.conf --dotcounts
20 else
21 file -b $TMPFILE | grep -i PDF > /dev/null
22 if [ $? -eq 0 ]
23 gs -q -dNOPAUSE $GSPARMS -sDEVICE=ppmraw
-sOutputFile=- $TMPFILE | $PDIR/z53 --config
z53.conf --dotcounts
24 else
25 enscript -B -o - $TMPFILE | gs -q -dNOPAUSE
$GSPARMS -sDEVICE=ppmraw -sOutputF ile=- -
| $PDIR/z53 --output blackonly --config z53.conf --dotcounts
26 fi
27 fi
28 /bin/rm -f $TMPFILE
29 }
30
31
32 runz53 2> /dev/null
Some of the lines are just too long to fit so they wrap around. But this
shouldn't cause us much confusion.
Let's walk through this program. First, the defined constants at the top,
lines 3,4,5.
Line 3 DEBUG = 0, may have no use, since it is not referred to elsewhere
in the script.
Line 4 PDIR simply points to where the lexmark software is installed.
Line 5 TMPFILE used by the mktemp command to generate a random name
for a file to hold the print job before it is filtered. This file is
needed only because this filter will handle pdf files, which need random
access to be properly processed. Text and postscript files could just
be piped.
Line 12 GSPARMS holds the ghostscript parameters based on what data the
user has given the lexmark setup program regarding paper size, resolution,
color vs black and white. At my current setting, echo $GSPARMS returns
-r600 -g5100x6600
Line 32 The script begins here. Why they used a subroutine isn't obvious
to me, but maybe it helps to redirect errors to /dev/null. So, go to
line 14.
line 15: This simply puts the file sent to the print filter all in the
$TMPFILE. Note that standard input is assumed but the file is redirected
to $TMPFILE.
Lines 17 to 24 are repetitive, just checking to see if the file is
either PDF or Postscript. If neither is the case, then enscript is
invoked to produce a postscript file. Now, I have never had a problem
with a linux application sending a PDF file to my printer. Acrobat prints
in postscript. And, since enscript -Z doesn't convert postscript files,
these lines could all be just left out.
The gs command just converts a postscript file to a ppmraw format, which is
then piped to the lexmark supplied driver for this printer with the
appropriate parameters. Let's rewrite this thing:
#!/bin/bash
PDIR=/usr/local/lexmark/z53
GSPARMS=`$PDIR/lxacgsparm z53.conf`
enscript -ZB -o - | gs -q -dNOPAUSE $GSPARMS -sDEVICE=ppmraw \
-sOutputFile=- - | $PDIR/z53 --config z53.conf
--dotcounts
Believe it or not, this works fine, both with text files and postscript
files, the only two types we expect to see coming to our printer. The
only problem might be the --output blackonly parameter which I left off
so I could get color printing. And, I am not sure where the errors are going
to be sent, if any. The -q parameter suppresses messages from gs.
============End tutorial==================
OK. You don't need to understand all the foregoing. Just know that z53.sh
is pointed at by the printcap entry. z53 is the real filter supplied
by lexmark.
What this makes clear is if you can get a postscript, text, or pdf file
to this queue, it will print it out. So, all my clients point to this
queue,and all send postscript jobs (windows 98/XPhome/XPpro/linux). The
printer driver which they all use is the HP laserjet + postscript,
or some such. This comes with all windows machines and linux if you use
cups. If you don't use cups, that's ok, because the default printing
format for linux is postscript.
It is also clear that you could use different z53.conf files for different
queues, and have draft, high quality, and photo quality printers defined
on your linux server for your clients to use.
So, here is my smb.conf entry for this printer. I DO NOT use the generic
printer share. This may avoid complications.
[global]
security = SHARE
guest account = ftp
[ps]
comment = Filtered for Z53
path = /tmp
read only = No
create mask = 0700
guest ok = yes
hosts allow = 192.168.
printable = Yes
printing = lprng
print command = echo %J %p %s >> /tmp/junkJ;\
a="`echo '%J' | sed "s/^.*- //"`" ;\
echo This is truncated $a >> /tmp/junkJ;\
/usr/bin/lpr -Pps -J"$a" %s;\
rm %s
lpq command = /usr/bin/lpq -Pps
lprm command = /usr/bin/lprm -Pps %j
lppause command = /usr/sbin/lpc hold ps %j
lpresume command = /usr/sbin/lpc release ps %j
share modes = No
use client driver = yes
[Photo]
comment = Print Photos
path = /tmp
read only = No
create mask = 0700
guest ok = yes
hosts allow = 192.168.
printable = Yes
printing = lprng
print command = echo %J %p %s >> /tmp/junkJ;\
a="`echo '%J' | sed "s/^.*- //"`" ;\
echo This is truncated $a >> /tmp/junkJ;\
/usr/bin/lpr -PPhoto -J"$a" %s;\
rm %s
lpq command = /usr/bin/lpq -PPhoto
lprm command = /usr/bin/lprm -PPhoto %j
lppause command = /usr/sbin/lpc hold Photo %j
lpresume command = /usr/sbin/lpc release Photo %j
share modes = No
use client driver = yes
I have two queue. One is ps for all print jobs. The other is Photo. This
queue is identical to ps except it uses, in the z53.sh script (renamed
z53Photo.sh), a different config file.
Now, if you use cups, you cannot define your own print commands. I would dump
cups and use lprng unless cups has something you have to have.
Here is my printcap on the server:
ps|z53:\
sh:sd=/var/spool/lpd/z53:mx#0:\
:lp=/dev/lp0:\
:if=/usr/local/lexmark/z53/z53.sh
:mc#1
:sh:
Photo:\
sh:sd=/var/spool/lpd/z53Photo:mx#0:\
:lp=/dev/lp0:\
:if=/usr/local/lexmark/z53/z53Photo.sh
:mc#1
lp|LP|z53-outfiles:\
:sd=/var/spool/lpd/lp:\
:mx#0:\
:lp=/dev/lp0:\
:sh:rw:
After you set up your printcap file, the command is checkpc -f to set up the
queues.
BTW, I like printing in samba now. All my printing works just fine. Adding
clients is very easy. It is so easy I use samba to service linux clients
as well as windows clients. I think that cups introduces complications
most users don't need. I don't save the drivers on the server. All
clients come with built in drivers for postscript printers.
This should give you something to work with. Good luck.
Joel
More information about the samba
mailing list