1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 >Debugging Printing Problems</TITLE
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.77"><LINK
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
13 TITLE="Printing Support in Samba 2.2.x"
14 HREF="printing.html"><LINK
16 TITLE="Security levels"
17 HREF="securitylevels.html"></HEAD
28 SUMMARY="Header navigation table"
37 >SAMBA Project Documentation</TH
59 HREF="securitylevels.html"
74 >Chapter 7. Debugging Printing Problems</H1
82 >7.1. Introduction</H1
84 >This is a short description of how to debug printing problems with
85 Samba. This describes how to debug problems with printing from a SMB
86 client to a Samba server, not the other way around. For the reverse
87 see the examples/printing directory.</P
89 >Ok, so you want to print to a Samba server from your PC. The first
90 thing you need to understand is that Samba does not actually do any
91 printing itself, it just acts as a middleman between your PC client
92 and your Unix printing subsystem. Samba receives the file from the PC
93 then passes the file to a external "print command". What print command
94 you use is up to you.</P
96 >The whole things is controlled using options in smb.conf. The most
97 relevant options (which you should look up in the smb.conf man page)
101 CLASS="PROGRAMLISTING"
103 print command - send a file to a spooler
104 lpq command - get spool queue status
105 lprm command - remove a job
107 path = /var/spool/lpd/samba</PRE
110 >The following are nice to know about:</P
113 CLASS="PROGRAMLISTING"
114 > queuepause command - stop a printer or print queue
115 queueresume command - start a printer or print queue</PRE
121 CLASS="PROGRAMLISTING"
122 > print command = /usr/bin/lpr -r -P%p %s
123 lpq command = /usr/bin/lpq -P%p %s
124 lprm command = /usr/bin/lprm -P%p %j
125 queuepause command = /usr/sbin/lpc -P%p stop
126 queuepause command = /usr/sbin/lpc -P%p start</PRE
129 >Samba should set reasonable defaults for these depending on your
130 system type, but it isn't clairvoyant. It is not uncommon that you
131 have to tweak these for local conditions. The commands should
132 always have fully specified pathnames, as the smdb may not have
133 the correct PATH values.</P
135 >When you send a job to Samba to be printed, it will make a temporary
136 copy of it in the directory specified in the [printers] section.
137 and it should be periodically cleaned out. The lpr -r option
138 requests that the temporary copy be removed after printing; If
139 printing fails then you might find leftover files in this directory,
140 and it should be periodically cleaned out. Samba used the lpq
141 command to determine the "job number" assigned to your print job
144 >The %>letter< are "macros" that get dynamically replaced with appropriate
145 values when they are used. The %s gets replaced with the name of the spool
146 file that Samba creates and the %p gets replaced with the name of the
147 printer. The %j gets replaced with the "job number" which comes from
157 >7.2. Debugging printer problems</H1
159 >One way to debug printing problems is to start by replacing these
160 command with shell scripts that record the arguments and the contents
161 of the print file. A simple example of this kind of things might
165 CLASS="PROGRAMLISTING"
166 > print command = /tmp/saveprint %p %s
169 # we make sure that we are the right user
170 /usr/bin/id -p >/tmp/tmp.print
171 # we run the command and save the error messages
172 # replace the command with the one appropriate for your system
173 /usr/bin/lpr -r -P$1 $2 2>>&/tmp/tmp.print</PRE
176 >Then you print a file and try removing it. You may find that the
177 print queue needs to be stopped in order to see the queue status
178 and remove the job:</P
181 CLASS="PROGRAMLISTING"
182 > h4: {42} % echo hi >/tmp/hi
183 h4: {43} % smbclient //localhost/lw4
184 added interface ip=10.0.0.4 bcast=10.0.0.255 nmask=255.255.255.0
186 Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
187 smb: \> print /tmp/hi
188 putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
191 smb: \> cancel 1049
192 Error cancelling job 1049 : code 0
193 smb: \> cancel 1049
196 smb: \> exit</PRE
199 >The 'code 0' indicates that the job was removed. The comment
200 by the smbclient is a bit misleading on this.
201 You can observe the command output and then and look at the
202 /tmp/tmp.print file to see what the results are. You can quickly
203 find out if the problem is with your printing system. Often people
204 have problems with their /etc/printcap file or permissions on
205 various print queues.</P
214 >7.3. What printers do I have?</H1
216 >You can use the 'testprns' program to check to see if the printer
217 name you are using is recognized by Samba. For example, you can
221 CLASS="PROGRAMLISTING"
222 > testprns printer /etc/printcap</PRE
225 >Samba can get its printcap information from a file or from a program.
226 You can try the following to see the format of the extracted
230 CLASS="PROGRAMLISTING"
231 > testprns -a printer /etc/printcap
233 testprns -a printer '|/bin/cat printcap'</PRE
243 >7.4. Setting up printcap and print servers</H1
245 >You may need to set up some printcaps for your Samba system to use.
246 It is strongly recommended that you use the facilities provided by
247 the print spooler to set up queues and printcap information.</P
249 >Samba requires either a printcap or program to deliver printcap
250 information. This printcap information has the format:</P
253 CLASS="PROGRAMLISTING"
254 > name|alias1|alias2...:option=value:...</PRE
257 >For almost all printing systems, the printer 'name' must be composed
258 only of alphanumeric or underscore '_' characters. Some systems also
259 allow hyphens ('-') as well. An alias is an alternative name for the
260 printer, and an alias with a space in it is used as a 'comment'
261 about the printer. The printcap format optionally uses a \ at the end of lines
262 to extend the printcap to multiple lines.</P
264 >Here are some examples of printcap files:</P
272 >pr just printer name</P
276 >pr|alias printer name and alias</P
280 >pr|My Printer printer name, alias used as comment</P
284 >pr:sh:\ Same as pr:sh:cm= testing
290 >pr:sh Same as pr:sh:cm= testing
296 >Samba reads the printcap information when first started. If you make
297 changes in the printcap information, then you must do the following:</P
304 >make sure that the print spooler is aware of these changes.
305 The LPRng system uses the 'lpc reread' command to do this.</P
309 >make sure that the spool queues, etc., exist and have the
310 correct permissions. The LPRng system uses the 'checkpc -f'
311 command to do this.</P
315 >You now should send a SIGHUP signal to the smbd server to have
316 it reread the printcap information.</P
327 >7.5. Job sent, no output</H1
329 >This is the most frustrating part of printing. You may have sent the
330 job, verified that the job was forwarded, set up a wrapper around
331 the command to send the file, but there was no output from the printer.</P
333 >First, check to make sure that the job REALLY is getting to the
334 right print queue. If you are using a BSD or LPRng print spooler,
335 you can temporarily stop the printing of jobs. Jobs can still be
336 submitted, but they will not be printed. Use:</P
339 CLASS="PROGRAMLISTING"
340 > lpc -Pprinter stop</PRE
343 >Now submit a print job and then use 'lpq -Pprinter' to see if the
344 job is in the print queue. If it is not in the print queue then
345 you will have to find out why it is not being accepted for printing.</P
347 >Next, you may want to check to see what the format of the job really
348 was. With the assistance of the system administrator you can view
349 the submitted jobs files. You may be surprised to find that these
350 are not in what you would expect to call a printable format.
351 You can use the UNIX 'file' utitily to determine what the job
352 format actually is:</P
355 CLASS="PROGRAMLISTING"
356 > cd /var/spool/lpd/printer # spool directory of print jobs
358 file dfA001myhost</PRE
361 >You should make sure that your printer supports this format OR that
362 your system administrator has installed a 'print filter' that will
363 convert the file to a format appropriate for your printer.</P
372 >7.6. Job sent, strange output</H1
374 >Once you have the job printing, you can then start worrying about
375 making it print nicely.</P
377 >The most common problem is extra pages of output: banner pages
378 OR blank pages at the end.</P
380 >If you are getting banner pages, check and make sure that the
381 printcap option or printer option is configured for no banners.
382 If you have a printcap, this is the :sh (suppress header or banner
383 page) option. You should have the following in your printer.</P
386 CLASS="PROGRAMLISTING"
387 > printer: ... :sh</PRE
390 >If you have this option and are still getting banner pages, there
391 is a strong chance that your printer is generating them for you
392 automatically. You should make sure that banner printing is disabled
393 for the printer. This usually requires using the printer setup software
394 or procedures supplied by the printer manufacturer.</P
396 >If you get an extra page of output, this could be due to problems
397 with your job format, or if you are generating PostScript jobs,
398 incorrect setting on your printer driver on the MicroSoft client.
399 For example, under Win95 there is a option:</P
402 CLASS="PROGRAMLISTING"
403 > Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|</PRE
406 >that allows you to choose if a Ctrl-D is appended to all jobs.
407 This is a very bad thing to do, as most spooling systems will
408 automatically add a ^D to the end of the job if it is detected as
409 PostScript. The multiple ^D may cause an additional page of output.</P
418 >7.7. Raw PostScript printed</H1
420 >This is a problem that is usually caused by either the print spooling
421 system putting information at the start of the print job that makes
422 the printer think the job is a text file, or your printer simply
423 does not support PostScript. You may need to enable 'Automatic
424 Format Detection' on your printer.</P
433 >7.8. Advanced Printing</H1
435 >Note that you can do some pretty magic things by using your
436 imagination with the "print command" option and some shell scripts.
437 Doing print accounting is easy by passing the %U option to a print
438 command shell script. You could even make the print command detect
439 the type of output and its size and send it to an appropriate
449 >7.9. Real debugging</H1
451 >If the above debug tips don't help, then maybe you need to bring in
452 the bug guns, system tracing. See Tracing.txt in this directory.</P
460 SUMMARY="Footer navigation table"
480 HREF="samba-howto-collection.html"
489 HREF="securitylevels.html"
499 >Printing Support in Samba 2.2.x</TD