This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[sfrench/samba-autobuild/.git] / docs / htmldocs / Printing.html
1 <HTML
2 ><HEAD
3 ><TITLE
4 >Debugging Printing Problems</TITLE
5 ><META
6 NAME="GENERATOR"
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.57"></HEAD
8 ><BODY
9 CLASS="ARTICLE"
10 BGCOLOR="#FFFFFF"
11 TEXT="#000000"
12 LINK="#0000FF"
13 VLINK="#840084"
14 ALINK="#0000FF"
15 ><DIV
16 CLASS="ARTICLE"
17 ><DIV
18 CLASS="TITLEPAGE"
19 ><H1
20 CLASS="TITLE"
21 ><A
22 NAME="PRINTING_DEBUG"
23 >Debugging Printing Problems</A
24 ></H1
25 ><HR></DIV
26 ><DIV
27 CLASS="SECT1"
28 ><H1
29 CLASS="SECT1"
30 ><A
31 NAME="AEN3"
32 >Introduction</A
33 ></H1
34 ><P
35 >This is a short description of how to debug printing problems with
36 Samba. This describes how to debug problems with printing from a SMB
37 client to a Samba server, not the other way around. For the reverse
38 see the examples/printing directory.</P
39 ><P
40 >Ok, so you want to print to a Samba server from your PC. The first
41 thing you need to understand is that Samba does not actually do any
42 printing itself, it just acts as a middleman between your PC client
43 and your Unix printing subsystem. Samba receives the file from the PC
44 then passes the file to a external "print command". What print command
45 you use is up to you.</P
46 ><P
47 >The whole things is controlled using options in smb.conf. The most
48 relevant options (which you should look up in the smb.conf man page)
49 are:</P
50 ><P
51 ><PRE
52 CLASS="PROGRAMLISTING"
53 >      [global]
54         print command     - send a file to a spooler
55         lpq command       - get spool queue status
56         lprm command      - remove a job
57       [printers]
58         path = /var/spool/lpd/samba</PRE
59 ></P
60 ><P
61 >The following are nice to know about:</P
62 ><P
63 ><PRE
64 CLASS="PROGRAMLISTING"
65 >        queuepause command   - stop a printer or print queue
66         queueresume command  - start a printer or print queue</PRE
67 ></P
68 ><P
69 >Example:</P
70 ><P
71 ><PRE
72 CLASS="PROGRAMLISTING"
73 >        print command = /usr/bin/lpr -r -P%p %s
74         lpq command   = /usr/bin/lpq    -P%p %s
75         lprm command  = /usr/bin/lprm   -P%p %j
76         queuepause command = /usr/sbin/lpc -P%p stop
77         queuepause command = /usr/sbin/lpc -P%p start</PRE
78 ></P
79 ><P
80 >Samba should set reasonable defaults for these depending on your
81 system type, but it isn't clairvoyant. It is not uncommon that you
82 have to tweak these for local conditions.  The commands should
83 always have fully specified pathnames,  as the smdb may not have
84 the correct PATH values.</P
85 ><P
86 >When you send a job to Samba to be printed,  it will make a temporary
87 copy of it in the directory specified in the [printers] section.
88 and it should be periodically cleaned out.  The lpr -r option
89 requests that the temporary copy be removed after printing; If
90 printing fails then you might find leftover files in this directory,
91 and it should be periodically cleaned out.  Samba used the lpq
92 command to determine the "job number" assigned to your print job
93 by the spooler.</P
94 ><P
95 >The %&gt;letter&lt; are "macros" that get dynamically replaced with appropriate
96 values when they are used. The %s gets replaced with the name of the spool
97 file that Samba creates and the %p gets replaced with the name of the
98 printer. The %j gets replaced with the "job number" which comes from
99 the lpq output.</P
100 ></DIV
101 ><DIV
102 CLASS="SECT1"
103 ><HR><H1
104 CLASS="SECT1"
105 ><A
106 NAME="AEN19"
107 >Debugging printer problems</A
108 ></H1
109 ><P
110 >One way to debug printing problems is to start by replacing these
111 command with shell scripts that record the arguments and the contents
112 of the print file. A simple example of this kind of things might
113 be:</P
114 ><P
115 ><PRE
116 CLASS="PROGRAMLISTING"
117 >       print command = /tmp/saveprint %p %s
118
119     #!/bin/saveprint
120     # we make sure that we are the right user
121     /usr/bin/id -p &#62;/tmp/tmp.print
122     # we run the command and save the error messages
123     # replace the command with the one appropriate for your system
124     /usr/bin/lpr -r -P$1 $2 2&#62;&#62;&#38;/tmp/tmp.print</PRE
125 ></P
126 ><P
127 >Then you print a file and try removing it.  You may find that the
128 print queue needs to be stopped in order to see the queue status
129 and remove the job:</P
130 ><P
131 ><PRE
132 CLASS="PROGRAMLISTING"
133 >&#13;h4: {42} % echo hi &#62;/tmp/hi
134 h4: {43} % smbclient //localhost/lw4
135 added interface ip=10.0.0.4 bcast=10.0.0.255 nmask=255.255.255.0
136 Password: 
137 Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
138 smb: \&#62; print /tmp/hi
139 putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
140 smb: \&#62; queue
141 1049     3            hi-17534
142 smb: \&#62; cancel 1049
143 Error cancelling job 1049 : code 0
144 smb: \&#62; cancel 1049
145 Job 1049 cancelled
146 smb: \&#62; queue
147 smb: \&#62; exit</PRE
148 ></P
149 ><P
150 >The 'code 0' indicates that the job was removed.  The comment
151 by the  smbclient is a bit misleading on this.
152 You can observe the command output and then and look at the
153 /tmp/tmp.print file to see what the results are.  You can quickly
154 find out if the problem is with your printing system.  Often people
155 have problems with their /etc/printcap file or permissions on
156 various print queues.</P
157 ></DIV
158 ><DIV
159 CLASS="SECT1"
160 ><HR><H1
161 CLASS="SECT1"
162 ><A
163 NAME="AEN28"
164 >What printers do I have?</A
165 ></H1
166 ><P
167 >You can use the 'testprns' program to check to see if the printer
168 name you are using is recognized by Samba.  For example,  you can
169 use:</P
170 ><P
171 ><PRE
172 CLASS="PROGRAMLISTING"
173 >    testprns printer /etc/printcap</PRE
174 ></P
175 ><P
176 >Samba can get its printcap information from a file or from a program.
177 You can try the following to see the format of the extracted
178 information:</P
179 ><P
180 ><PRE
181 CLASS="PROGRAMLISTING"
182 >    testprns -a printer /etc/printcap
183
184     testprns -a printer '|/bin/cat printcap'</PRE
185 ></P
186 ></DIV
187 ><DIV
188 CLASS="SECT1"
189 ><HR><H1
190 CLASS="SECT1"
191 ><A
192 NAME="AEN36"
193 >Setting up printcap and print servers</A
194 ></H1
195 ><P
196 >You may need to set up some printcaps for your Samba system to use.
197 It is strongly recommended that you use the facilities provided by
198 the print spooler to set up queues and printcap information.</P
199 ><P
200 >Samba requires either a printcap or program to deliver printcap
201 information.  This printcap information has the format:</P
202 ><P
203 ><PRE
204 CLASS="PROGRAMLISTING"
205 >  name|alias1|alias2...:option=value:...</PRE
206 ></P
207 ><P
208 >For almost all printing systems, the printer 'name' must be composed
209 only of alphanumeric or underscore '_' characters.  Some systems also
210 allow hyphens ('-') as well.  An alias is an alternative name for the
211 printer,  and an alias with a space in it is used as a 'comment'
212 about the printer.  The printcap format optionally uses a \ at the end of lines
213 to extend the printcap to multiple lines.</P
214 ><P
215 >Here are some examples of printcap files:</P
216 ><P
217 ><P
218 ></P
219 ><OL
220 TYPE="1"
221 ><LI
222 ><P
223 >pr              just printer name</P
224 ></LI
225 ><LI
226 ><P
227 >pr|alias        printer name and alias</P
228 ></LI
229 ><LI
230 ><P
231 >pr|My Printer   printer name, alias used as comment</P
232 ></LI
233 ><LI
234 ><P
235 >pr:sh:\        Same as pr:sh:cm= testing
236   :cm= \ 
237   testing</P
238 ></LI
239 ><LI
240 ><P
241 >pr:sh           Same as pr:sh:cm= testing
242   :cm= testing</P
243 ></LI
244 ></OL
245 ></P
246 ><P
247 >Samba reads the printcap information when first started.  If you make
248 changes in the printcap information, then you must do the following:</P
249 ><P
250 ></P
251 ><OL
252 TYPE="1"
253 ><LI
254 ><P
255 >make sure that the print spooler is aware of these changes.
256 The LPRng system uses the 'lpc reread' command to do this.</P
257 ></LI
258 ><LI
259 ><P
260 >make sure that the spool queues, etc., exist and have the
261 correct permissions.  The LPRng system uses the 'checkpc -f'
262 command to do this.</P
263 ></LI
264 ><LI
265 ><P
266 >You now should send a SIGHUP signal to the smbd server to have
267 it reread the printcap information.</P
268 ></LI
269 ></OL
270 ></DIV
271 ><DIV
272 CLASS="SECT1"
273 ><HR><H1
274 CLASS="SECT1"
275 ><A
276 NAME="AEN64"
277 >Job sent, no output</A
278 ></H1
279 ><P
280 >This is the most frustrating part of printing.  You may have sent the
281 job,  verified that the job was forwarded,  set up a wrapper around
282 the command to send the file,  but there was no output from the printer.</P
283 ><P
284 >First,  check to make sure that the job REALLY is getting to the
285 right print queue.  If you are using a BSD or LPRng print spooler,
286 you can temporarily stop the printing of jobs.  Jobs can still be
287 submitted, but they will not be printed.  Use:</P
288 ><P
289 ><PRE
290 CLASS="PROGRAMLISTING"
291 >  lpc -Pprinter stop</PRE
292 ></P
293 ><P
294 >Now submit a print job and then use 'lpq -Pprinter' to see if the
295 job is in the print queue.  If it is not in the print queue then
296 you will have to find out why it is not being accepted for printing.</P
297 ><P
298 >Next, you may want to check to see what the format of the job really
299 was.  With the assistance of the system administrator you can view
300 the submitted jobs files.  You may be surprised to find that these
301 are not in what you would expect to call a printable format.
302 You can use the UNIX 'file' utitily to determine what the job
303 format actually is:</P
304 ><P
305 ><PRE
306 CLASS="PROGRAMLISTING"
307 >    cd /var/spool/lpd/printer   # spool directory of print jobs
308     ls                          # find job files
309     file dfA001myhost</PRE
310 ></P
311 ><P
312 >You should make sure that your printer supports this format OR that
313 your system administrator has installed a 'print filter' that will
314 convert the file to a format appropriate for your printer.</P
315 ></DIV
316 ><DIV
317 CLASS="SECT1"
318 ><HR><H1
319 CLASS="SECT1"
320 ><A
321 NAME="AEN75"
322 >Job sent, strange output</A
323 ></H1
324 ><P
325 >Once you have the job printing, you can then start worrying about
326 making it print nicely.</P
327 ><P
328 >The most common problem is extra pages of output: banner pages
329 OR blank pages at the end.</P
330 ><P
331 >If you are getting banner pages,  check and make sure that the
332 printcap option or printer option is configured for no banners.
333 If you have a printcap,  this is the :sh (suppress header or banner
334 page) option.  You should have the following in your printer.</P
335 ><P
336 ><PRE
337 CLASS="PROGRAMLISTING"
338 >   printer: ... :sh</PRE
339 ></P
340 ><P
341 >If you have this option and are still getting banner pages,  there
342 is a strong chance that your printer is generating them for you
343 automatically.  You should make sure that banner printing is disabled
344 for the printer.  This usually requires using the printer setup software
345 or procedures supplied by the printer manufacturer.</P
346 ><P
347 >If you get an extra page of output,  this could be due to problems
348 with your job format,  or if you are generating PostScript jobs,
349 incorrect setting on your printer driver on the MicroSoft client.
350 For example, under Win95 there is a option:</P
351 ><P
352 ><PRE
353 CLASS="PROGRAMLISTING"
354 >  Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|</PRE
355 ></P
356 ><P
357 >that allows you to choose if a Ctrl-D is appended to all jobs.
358 This is a very bad thing to do, as most spooling systems will
359 automatically add a ^D to the end of the job if it is detected as
360 PostScript.  The multiple ^D may cause an additional page of output.</P
361 ></DIV
362 ><DIV
363 CLASS="SECT1"
364 ><HR><H1
365 CLASS="SECT1"
366 ><A
367 NAME="AEN87"
368 >Raw PostScript printed</A
369 ></H1
370 ><P
371 >This is a problem that is usually caused by either the print spooling
372 system putting information at the start of the print job that makes
373 the printer think the job is a text file, or your printer simply
374 does not support PostScript.  You may need to enable 'Automatic
375 Format Detection' on your printer.</P
376 ></DIV
377 ><DIV
378 CLASS="SECT1"
379 ><HR><H1
380 CLASS="SECT1"
381 ><A
382 NAME="AEN90"
383 >Advanced Printing</A
384 ></H1
385 ><P
386 >Note that you can do some pretty magic things by using your
387 imagination with the "print command" option and some shell scripts.
388 Doing print accounting is easy by passing the %U option to a print
389 command shell script. You could even make the print command detect
390 the type of output and its size and send it to an appropriate
391 printer.</P
392 ></DIV
393 ><DIV
394 CLASS="SECT1"
395 ><HR><H1
396 CLASS="SECT1"
397 ><A
398 NAME="AEN93"
399 >Real debugging</A
400 ></H1
401 ><P
402 >If the above debug tips don't help, then maybe you need to bring in
403 the bug guns, system tracing. See Tracing.txt in this directory.</P
404 ></DIV
405 ></DIV
406 ></BODY
407 ></HTML
408 >