LPRng: Printing to Samba 2.0.7 from Windows 2000
papowell at astart.com
papowell at astart.com
Fri Aug 11 22:13:58 GMT 2000
> From lprng at astart2.astart.com Fri Aug 11 14:51:22 2000
> Date: Fri, 11 Aug 2000 13:38:04 -0700 (PDT)
> From: John Johnson <ioann_j at yahoo.com>
> Subject: LPRng: Printing to Samba 2.0.7 from Windows 2000
> To: lprng at lprng.com, freebsd-questions at FreeBSD.ORG, samba at samba.org
> I've recently installed LPRng 3.6.22, ifhp 3.3.19, and
> Samba 2.0.7 on my FreeBSD 4.1 system. Printing works
> fine from the FreeBSD machine, and I am able to access
> shares via my Win2000 machine. I've configured a
> [printers] section in smb.conf, and I am able to see
> the LaserJet 2100 when browsing, but on installing it
> I am unable to print to it. I get en error connecting
> the printer message, nothing else.
> Can anyone steer me in the right direction? Copied
> below are my smb.conf and printcap settings. I've not
> inlcluded ifhp.conf, lpd.conf or lpd.perms as these
> are stock and have not been modified.
> Please Reply to All, as I've not been receiving e-mail
> from Samba or LPRng of late.
> Thanks in advance,
Amazing. The folks are telephathic. Here is the revised
Samba samba/docs/textdocs/Printing.txt document that I just
finished this morning.
Patrick Powell Astart Technologies,
papowell at astart.com 9475 Chesapeake Drive, Suite D,
Network and System San Diego, CA 92123
Consulting 858-874-6543 FAX 858-279-8424
LPRng - Print Spooler (http://www.astart.com)
!== Printing.txt for Samba release 2.0.4 18 May 1999
Contributor: Unknown <samba-bugs at samba.org>
Subject: Dubugging Printing Problems
This is a short description of how to debug printing problems with
Samba. This describes how to debug problems with printing from a SMB
client to a Samba server, not the other way around. For the reverse
see the examples/printing directory.
Please send enhancements to this file to samba-bugs at samba.org
Ok, so you want to print to a Samba server from your PC. The first
thing you need to understand is that Samba does not actually do any
printing itself, it just acts as a middleman between your PC client
and your Unix printing subsystem. Samba receives the file from the PC
then passes the file to a external "print command". What print command
you use is up to you.
The whole things is controlled using options in smb.conf. The most
relevant options (which you should look up in the smb.conf man page)
print command - send a file to a spooler
lpq command - get spool queue status
lprm command - remove a job
path = /var/spool/lpd/samba
The following are nice to know about:
queuepause command - stop a printer or print queue
queueresume command - start a printer or print queue
print command = /usr/bin/lpr -r -P%p %s
lpq command = /usr/bin/lpq -P%p %s
lprm command = /usr/bin/lprm -P%p %j
queuepause command = /usr/sbin/lpc -P%p stop
queuepause command = /usr/sbin/lpc -P%p start
Samba should set reasonable defaults for these depending on your
system type, but it isn't clairvoyant. It is not uncommon that you
have to tweak these for local conditions. The commands should
always have fully specified pathnames, as the smdb may not have
the correct PATH values.
When you send a job to Samba to be printed, it will make a temporary
copy of it in the directory specified in the [printers] section.
and it should be periodically cleaned out. The lpr -r option
requests that the temporary copy be removed after printing; If
printing fails then you might find leftover files in this directory,
and it should be periodically cleaned out. Samba used the lpq
command to determine the "job number" assigned to your print job
by the spooler.
The %<letter> are "macros" that get dynamically replaced with appropriate
values when they are used. The %s gets replaced with the name of the spool
file that Samba creates and the %p gets replaced with the name of the
printer. The %j gets replaced with the "job number" which comes from
the lpq output.
DEBUGGING PRINTER PROBLEMS
One way to debug printing problems is to start by replacing these
command with shell scripts that record the arguments and the contents
of the print file. A simple example of this kind of things might
print command = /tmp/saveprint %p %s
# we make sure that we are the right user
/usr/bin/id -p >/tmp/tmp.print
# we run the command and save the error messages
# replace the command with the one appropriate for your system
/usr/bin/lpr -r -P$1 $2 2>>&/tmp/tmp.print
Then you print a file:
echo "print /tmp/test" |
smbclient //server/pr password -Uuser
You can observe the command output and then and look at the
/tmp/tmp.print file to see what the results are. You can quickly
find out if the problem is with your printing system. Often people
have problems with their /etc/printcap file or permissions on
various print queues.
WHAT PRINTERS DO I HAVE
You can use the 'testprns' program to check to see if the printer
name you are using is recognized by Samba. For example, you can
testprns printer /etc/printcap
Samba can get its printcap information from a file or from a program.
You can try the following to see the format of the extracted
testprns -a printer /etc/printcap
testprns -a printer '|/bin/cat printcap'
SETTING UP PRINTCAP AND PRINT SERVERS
You may need to set up some printcaps for your Samba system to use.
It is strongly recommended that you use the facilities provided by
the print spooler to set up queues and printcap information.
Samba requires either a printcap or program to deliver printcap
information. This printcap information has the format:
For almost all printing systems, the printer 'name' must be composed
only of alphanumeric or underscore '_' characters. Some systems also
allow hyphens ('-') as well. An alias is an alternative name for the
printer, and an alias with a space in it is used as a 'comment'
about the printer. The printcap format optionally uses a \ at the end of lines
to extend the printcap to multiple lines.
Here are some examples of printcap files:
pr just printer name
pr|alias printer name and alias
pr|My Printer printer name, alias used as comment
pr:sh:\ Same as pr:sh:cm= testing
pr:sh Same as pr:sh:cm= testing
Samba reads the printcap information when first started. If you make
changes in the printcap information, then you must do the following:
a) make sure that the print spooler is aware of these changes.
The LPRng system uses the 'lpc reread' command to do this.
b) make sure that the spool queues, etc., exist and have the
correct permissions. The LPRng system uses the 'checkpc -f'
command to do this.
c) You now should send a SIGHUP signal to the smbd server to have
it reread the printcap information.
JOB SENT, NO OUTPUT
This is the most frustrating part of printing. You may have sent the
job, verified that the job was forwarded, set up a wrapper around
the command to send the file, but there was no output from the printer.
First, check to make sure that the job REALLY is getting to the
right print queue. If you are using a BSD or LPRng print spooler,
you can temporarily stop the printing of jobs. Jobs can still be
submitted, but they will not be printed. Use:
lpc -Pprinter stop
Now submit a print job and then use 'lpq -Pprinter' to see if the
job is in the print queue. If it is not in the print queue then
you will have to find out why it is not being accepted for printing.
Next, you may want to check to see what the format of the job really
was. With the assistance of the system administrator you can view
the submitted jobs files. You may be surprised to find that these
are not in what you would expect to call a printable format.
You can use the UNIX 'file' utitily to determine what the job
format actually is:
cd /var/spool/lpd/printer # spool directory of print jobs
ls # find job files
You should make sure that your printer supports this format OR that
your system administrator has installed a 'print filter' that will
convert the file to a format appropriate for your printer.
JOB SENT, STRANGE OUTPUT
Once you have the job printing, you can then start worrying about
making it print nicely.
The most common problem is extra pages of output: banner pages
OR blank pages at the end.
If you are getting banner pages, check and make sure that the
printcap option or printer option is configured for no banners.
If you have a printcap, this is the :sh (suppress header or banner
page) option. You should have the following in your printer.
printer: ... :sh
If you have this option and are still getting banner pages, there
is a strong chance that your printer is generating them for you
automatically. You should make sure that banner printing is disabled
for the printer. This usually requires using the printer setup software
or procedures supplied by the printer manufacturer.
If you get an extra page of output, this could be due to problems
with your job format, or if you are generating PostScript jobs,
incorrect setting on your printer driver on the MicroSoft client.
For example, under Win95 there is a option:
Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|
that allows you to choose if a Ctrl-D is appended to all jobs.
This is a very bad thing to do, as most spooling systems will
automatically add a ^D to the end of the job if it is detected as
PostScript. The multiple ^D may cause an additional page of output.
RAW POSTSCRIPT PRINTED
This is a problem that is usually caused by either the print spooling
system putting information at the start of the print job that makes
the printer think the job is a text file, or your printer simply
does not support PostScript. You may need to enable 'Automatic
Format Detection' on your printer.
Note that you can do some pretty magic things by using your
imagination with the "print command" option and some shell scripts.
Doing print accounting is easy by passing the %U option to a print
command shell script. You could even make the print command detect
the type of output and its size and send it to an appropriate
If the above debug tips don't help, then maybe you need to bring in
the bug guns, system tracing. See Tracing.txt in this directory.
More information about the samba