1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
<HTML
><HEAD
><TITLE
>Debugging Printing Problems</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"></HEAD
><BODY
CLASS="ARTICLE"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="ARTICLE"
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="TITLE"
><A
NAME="PRINTING_DEBUG"
>Debugging Printing Problems</A
></H1
><HR></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN3"
>Introduction</A
></H1
><P
>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.</P
><P
>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.</P
><P
>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)
are:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> [global]
print command - send a file to a spooler
lpq command - get spool queue status
lprm command - remove a job
[printers]
path = /var/spool/lpd/samba</PRE
></P
><P
>The following are nice to know about:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> queuepause command - stop a printer or print queue
queueresume command - start a printer or print queue</PRE
></P
><P
>Example:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> 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</PRE
></P
><P
>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.</P
><P
>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.</P
><P
>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.</P
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN19"
>Debugging printer problems</A
></H1
><P
>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
be:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> print command = /tmp/saveprint %p %s
#!/bin/saveprint
# 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</PRE
></P
><P
>Then you print a file and try removing it. You may find that the
print queue needs to be stopped in order to see the queue status
and remove the job:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> h4: {42} % echo hi >/tmp/hi
h4: {43} % smbclient //localhost/lw4
added interface ip=10.0.0.4 bcast=10.0.0.255 nmask=255.255.255.0
Password:
Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
smb: \> print /tmp/hi
putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
smb: \> queue
1049 3 hi-17534
smb: \> cancel 1049
Error cancelling job 1049 : code 0
smb: \> cancel 1049
Job 1049 cancelled
smb: \> queue
smb: \> exit</PRE
></P
><P
>The 'code 0' indicates that the job was removed. The comment
by the smbclient is a bit misleading on this.
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.</P
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN28"
>What printers do I have?</A
></H1
><P
>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
use:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> testprns printer /etc/printcap</PRE
></P
><P
>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
information:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> testprns -a printer /etc/printcap
testprns -a printer '|/bin/cat printcap'</PRE
></P
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN36"
>Setting up printcap and print servers</A
></H1
><P
>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.</P
><P
>Samba requires either a printcap or program to deliver printcap
information. This printcap information has the format:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> name|alias1|alias2...:option=value:...</PRE
></P
><P
>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.</P
><P
>Here are some examples of printcap files:</P
><P
><P
></P
><OL
TYPE="1"
><LI
><P
>pr just printer name</P
></LI
><LI
><P
>pr|alias printer name and alias</P
></LI
><LI
><P
>pr|My Printer printer name, alias used as comment</P
></LI
><LI
><P
>pr:sh:\ Same as pr:sh:cm= testing
:cm= \
testing</P
></LI
><LI
><P
>pr:sh Same as pr:sh:cm= testing
:cm= testing</P
></LI
></OL
></P
><P
>Samba reads the printcap information when first started. If you make
changes in the printcap information, then you must do the following:</P
><P
></P
><OL
TYPE="1"
><LI
><P
>make sure that the print spooler is aware of these changes.
The LPRng system uses the 'lpc reread' command to do this.</P
></LI
><LI
><P
>make sure that the spool queues, etc., exist and have the
correct permissions. The LPRng system uses the 'checkpc -f'
command to do this.</P
></LI
><LI
><P
>You now should send a SIGHUP signal to the smbd server to have
it reread the printcap information.</P
></LI
></OL
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN64"
>Job sent, no output</A
></H1
><P
>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.</P
><P
>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:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> lpc -Pprinter stop</PRE
></P
><P
>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.</P
><P
>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:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> cd /var/spool/lpd/printer # spool directory of print jobs
ls # find job files
file dfA001myhost</PRE
></P
><P
>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.</P
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN75"
>Job sent, strange output</A
></H1
><P
>Once you have the job printing, you can then start worrying about
making it print nicely.</P
><P
>The most common problem is extra pages of output: banner pages
OR blank pages at the end.</P
><P
>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.</P
><P
><PRE
CLASS="PROGRAMLISTING"
> printer: ... :sh</PRE
></P
><P
>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.</P
><P
>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:</P
><P
><PRE
CLASS="PROGRAMLISTING"
> Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|</PRE
></P
><P
>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.</P
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN87"
>Raw PostScript printed</A
></H1
><P
>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.</P
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN90"
>Advanced Printing</A
></H1
><P
>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
printer.</P
></DIV
><DIV
CLASS="SECT1"
><HR><H1
CLASS="SECT1"
><A
NAME="AEN93"
>Real debugging</A
></H1
><P
>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.</P
></DIV
></DIV
></BODY
></HTML
>
|