4 >Debugging Printing Problems</TITLE
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.57"></HEAD
23 >Debugging Printing Problems</A
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
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
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)
52 CLASS="PROGRAMLISTING"
54 print command - send a file to a spooler
55 lpq command - get spool queue status
56 lprm command - remove a job
58 path = /var/spool/lpd/samba</PRE
61 >The following are nice to know about:</P
64 CLASS="PROGRAMLISTING"
65 > queuepause command - stop a printer or print queue
66 queueresume command - start a printer or print queue</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
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
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
95 >The %>letter< 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
107 >Debugging printer problems</A
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
116 CLASS="PROGRAMLISTING"
117 > print command = /tmp/saveprint %p %s
120 # we make sure that we are the right user
121 /usr/bin/id -p >/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>>&/tmp/tmp.print</PRE
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
132 CLASS="PROGRAMLISTING"
133 > h4: {42} % echo hi >/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
137 Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
138 smb: \> print /tmp/hi
139 putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
142 smb: \> cancel 1049
143 Error cancelling job 1049 : code 0
144 smb: \> cancel 1049
147 smb: \> exit</PRE
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
164 >What printers do I have?</A
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
172 CLASS="PROGRAMLISTING"
173 > testprns printer /etc/printcap</PRE
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
181 CLASS="PROGRAMLISTING"
182 > testprns -a printer /etc/printcap
184 testprns -a printer '|/bin/cat printcap'</PRE
193 >Setting up printcap and print servers</A
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
200 >Samba requires either a printcap or program to deliver printcap
201 information. This printcap information has the format:</P
204 CLASS="PROGRAMLISTING"
205 > name|alias1|alias2...:option=value:...</PRE
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
215 >Here are some examples of printcap files:</P
223 >pr just printer name</P
227 >pr|alias printer name and alias</P
231 >pr|My Printer printer name, alias used as comment</P
235 >pr:sh:\ Same as pr:sh:cm= testing
241 >pr:sh Same as pr:sh:cm= testing
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
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
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
266 >You now should send a SIGHUP signal to the smbd server to have
267 it reread the printcap information.</P
277 >Job sent, no output</A
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
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
290 CLASS="PROGRAMLISTING"
291 > lpc -Pprinter stop</PRE
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
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
306 CLASS="PROGRAMLISTING"
307 > cd /var/spool/lpd/printer # spool directory of print jobs
309 file dfA001myhost</PRE
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
322 >Job sent, strange output</A
325 >Once you have the job printing, you can then start worrying about
326 making it print nicely.</P
328 >The most common problem is extra pages of output: banner pages
329 OR blank pages at the end.</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
337 CLASS="PROGRAMLISTING"
338 > printer: ... :sh</PRE
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
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
353 CLASS="PROGRAMLISTING"
354 > Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|</PRE
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
368 >Raw PostScript printed</A
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
383 >Advanced Printing</A
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
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