This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[samba.git] / docs / htmldocs / printingdebug.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Debugging Printing Problems</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.77"><LINK
9 REL="HOME"
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
12 REL="PREVIOUS"
13 TITLE="Printing Support in Samba 2.2.x"
14 HREF="printing.html"><LINK
15 REL="NEXT"
16 TITLE="Security levels"
17 HREF="securitylevels.html"></HEAD
18 ><BODY
19 CLASS="CHAPTER"
20 BGCOLOR="#FFFFFF"
21 TEXT="#000000"
22 LINK="#0000FF"
23 VLINK="#840084"
24 ALINK="#0000FF"
25 ><DIV
26 CLASS="NAVHEADER"
27 ><TABLE
28 SUMMARY="Header navigation table"
29 WIDTH="100%"
30 BORDER="0"
31 CELLPADDING="0"
32 CELLSPACING="0"
33 ><TR
34 ><TH
35 COLSPAN="3"
36 ALIGN="center"
37 >SAMBA Project Documentation</TH
38 ></TR
39 ><TR
40 ><TD
41 WIDTH="10%"
42 ALIGN="left"
43 VALIGN="bottom"
44 ><A
45 HREF="printing.html"
46 ACCESSKEY="P"
47 >Prev</A
48 ></TD
49 ><TD
50 WIDTH="80%"
51 ALIGN="center"
52 VALIGN="bottom"
53 ></TD
54 ><TD
55 WIDTH="10%"
56 ALIGN="right"
57 VALIGN="bottom"
58 ><A
59 HREF="securitylevels.html"
60 ACCESSKEY="N"
61 >Next</A
62 ></TD
63 ></TR
64 ></TABLE
65 ><HR
66 ALIGN="LEFT"
67 WIDTH="100%"></DIV
68 ><DIV
69 CLASS="CHAPTER"
70 ><H1
71 ><A
72 NAME="PRINTINGDEBUG"
73 ></A
74 >Chapter 7. Debugging Printing Problems</H1
75 ><DIV
76 CLASS="SECT1"
77 ><H1
78 CLASS="SECT1"
79 ><A
80 NAME="AEN986"
81 ></A
82 >7.1. Introduction</H1
83 ><P
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
88 ><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
95 ><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)
98 are:</P
99 ><P
100 ><PRE
101 CLASS="PROGRAMLISTING"
102 >      [global]
103         print command     - send a file to a spooler
104         lpq command       - get spool queue status
105         lprm command      - remove a job
106       [printers]
107         path = /var/spool/lpd/samba</PRE
108 ></P
109 ><P
110 >The following are nice to know about:</P
111 ><P
112 ><PRE
113 CLASS="PROGRAMLISTING"
114 >        queuepause command   - stop a printer or print queue
115         queueresume command  - start a printer or print queue</PRE
116 ></P
117 ><P
118 >Example:</P
119 ><P
120 ><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
127 ></P
128 ><P
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
134 ><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
142 by the spooler.</P
143 ><P
144 >The %&gt;letter&lt; 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
148 the lpq output.</P
149 ></DIV
150 ><DIV
151 CLASS="SECT1"
152 ><H1
153 CLASS="SECT1"
154 ><A
155 NAME="AEN1002"
156 ></A
157 >7.2. Debugging printer problems</H1
158 ><P
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
162 be:</P
163 ><P
164 ><PRE
165 CLASS="PROGRAMLISTING"
166 >       print command = /tmp/saveprint %p %s
167
168     #!/bin/saveprint
169     # we make sure that we are the right user
170     /usr/bin/id -p &#62;/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&#62;&#62;&#38;/tmp/tmp.print</PRE
174 ></P
175 ><P
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
179 ><P
180 ><PRE
181 CLASS="PROGRAMLISTING"
182 >&#13;h4: {42} % echo hi &#62;/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
185 Password: 
186 Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
187 smb: \&#62; print /tmp/hi
188 putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
189 smb: \&#62; queue
190 1049     3            hi-17534
191 smb: \&#62; cancel 1049
192 Error cancelling job 1049 : code 0
193 smb: \&#62; cancel 1049
194 Job 1049 cancelled
195 smb: \&#62; queue
196 smb: \&#62; exit</PRE
197 ></P
198 ><P
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
206 ></DIV
207 ><DIV
208 CLASS="SECT1"
209 ><H1
210 CLASS="SECT1"
211 ><A
212 NAME="AEN1011"
213 ></A
214 >7.3. What printers do I have?</H1
215 ><P
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
218 use:</P
219 ><P
220 ><PRE
221 CLASS="PROGRAMLISTING"
222 >    testprns printer /etc/printcap</PRE
223 ></P
224 ><P
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
227 information:</P
228 ><P
229 ><PRE
230 CLASS="PROGRAMLISTING"
231 >    testprns -a printer /etc/printcap
232
233     testprns -a printer '|/bin/cat printcap'</PRE
234 ></P
235 ></DIV
236 ><DIV
237 CLASS="SECT1"
238 ><H1
239 CLASS="SECT1"
240 ><A
241 NAME="AEN1019"
242 ></A
243 >7.4. Setting up printcap and print servers</H1
244 ><P
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
248 ><P
249 >Samba requires either a printcap or program to deliver printcap
250 information.  This printcap information has the format:</P
251 ><P
252 ><PRE
253 CLASS="PROGRAMLISTING"
254 >  name|alias1|alias2...:option=value:...</PRE
255 ></P
256 ><P
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
263 ><P
264 >Here are some examples of printcap files:</P
265 ><P
266 ><P
267 ></P
268 ><OL
269 TYPE="1"
270 ><LI
271 ><P
272 >pr              just printer name</P
273 ></LI
274 ><LI
275 ><P
276 >pr|alias        printer name and alias</P
277 ></LI
278 ><LI
279 ><P
280 >pr|My Printer   printer name, alias used as comment</P
281 ></LI
282 ><LI
283 ><P
284 >pr:sh:\        Same as pr:sh:cm= testing
285   :cm= \ 
286   testing</P
287 ></LI
288 ><LI
289 ><P
290 >pr:sh           Same as pr:sh:cm= testing
291   :cm= testing</P
292 ></LI
293 ></OL
294 ></P
295 ><P
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
298 ><P
299 ></P
300 ><OL
301 TYPE="1"
302 ><LI
303 ><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
306 ></LI
307 ><LI
308 ><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
312 ></LI
313 ><LI
314 ><P
315 >You now should send a SIGHUP signal to the smbd server to have
316 it reread the printcap information.</P
317 ></LI
318 ></OL
319 ></DIV
320 ><DIV
321 CLASS="SECT1"
322 ><H1
323 CLASS="SECT1"
324 ><A
325 NAME="AEN1047"
326 ></A
327 >7.5. Job sent, no output</H1
328 ><P
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
332 ><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
337 ><P
338 ><PRE
339 CLASS="PROGRAMLISTING"
340 >  lpc -Pprinter stop</PRE
341 ></P
342 ><P
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
346 ><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
353 ><P
354 ><PRE
355 CLASS="PROGRAMLISTING"
356 >    cd /var/spool/lpd/printer   # spool directory of print jobs
357     ls                          # find job files
358     file dfA001myhost</PRE
359 ></P
360 ><P
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
364 ></DIV
365 ><DIV
366 CLASS="SECT1"
367 ><H1
368 CLASS="SECT1"
369 ><A
370 NAME="AEN1058"
371 ></A
372 >7.6. Job sent, strange output</H1
373 ><P
374 >Once you have the job printing, you can then start worrying about
375 making it print nicely.</P
376 ><P
377 >The most common problem is extra pages of output: banner pages
378 OR blank pages at the end.</P
379 ><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
384 ><P
385 ><PRE
386 CLASS="PROGRAMLISTING"
387 >   printer: ... :sh</PRE
388 ></P
389 ><P
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
395 ><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
400 ><P
401 ><PRE
402 CLASS="PROGRAMLISTING"
403 >  Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|</PRE
404 ></P
405 ><P
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
410 ></DIV
411 ><DIV
412 CLASS="SECT1"
413 ><H1
414 CLASS="SECT1"
415 ><A
416 NAME="AEN1070"
417 ></A
418 >7.7. Raw PostScript printed</H1
419 ><P
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
425 ></DIV
426 ><DIV
427 CLASS="SECT1"
428 ><H1
429 CLASS="SECT1"
430 ><A
431 NAME="AEN1073"
432 ></A
433 >7.8. Advanced Printing</H1
434 ><P
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
440 printer.</P
441 ></DIV
442 ><DIV
443 CLASS="SECT1"
444 ><H1
445 CLASS="SECT1"
446 ><A
447 NAME="AEN1076"
448 ></A
449 >7.9. Real debugging</H1
450 ><P
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
453 ></DIV
454 ></DIV
455 ><DIV
456 CLASS="NAVFOOTER"
457 ><HR
458 ALIGN="LEFT"
459 WIDTH="100%"><TABLE
460 SUMMARY="Footer navigation table"
461 WIDTH="100%"
462 BORDER="0"
463 CELLPADDING="0"
464 CELLSPACING="0"
465 ><TR
466 ><TD
467 WIDTH="33%"
468 ALIGN="left"
469 VALIGN="top"
470 ><A
471 HREF="printing.html"
472 ACCESSKEY="P"
473 >Prev</A
474 ></TD
475 ><TD
476 WIDTH="34%"
477 ALIGN="center"
478 VALIGN="top"
479 ><A
480 HREF="samba-howto-collection.html"
481 ACCESSKEY="H"
482 >Home</A
483 ></TD
484 ><TD
485 WIDTH="33%"
486 ALIGN="right"
487 VALIGN="top"
488 ><A
489 HREF="securitylevels.html"
490 ACCESSKEY="N"
491 >Next</A
492 ></TD
493 ></TR
494 ><TR
495 ><TD
496 WIDTH="33%"
497 ALIGN="left"
498 VALIGN="top"
499 >Printing Support in Samba 2.2.x</TD
500 ><TD
501 WIDTH="34%"
502 ALIGN="center"
503 VALIGN="top"
504 >&nbsp;</TD
505 ><TD
506 WIDTH="33%"
507 ALIGN="right"
508 VALIGN="top"
509 >Security levels</TD
510 ></TR
511 ></TABLE
512 ></DIV
513 ></BODY
514 ></HTML
515 >