This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[ira/wip.git] / docs / textdocs / Printing.txt
1 Contributor:    Unknown <samba@samba.org>
2 Revised by:     Patrick Powell <papowell@lprng.org>
3 Date:           August 11, 2000
4 Status:         Current
5
6 Subject:        Dubugging Printing Problems
7 =============================================================================
8
9 This is a short description of how to debug printing problems with
10 Samba. This describes how to debug problems with printing from a SMB
11 client to a Samba server, not the other way around. For the reverse
12 see the examples/printing directory.
13
14 Please send enhancements to this file to samba@samba.org
15
16 Ok, so you want to print to a Samba server from your PC. The first
17 thing you need to understand is that Samba does not actually do any
18 printing itself, it just acts as a middleman between your PC client
19 and your Unix printing subsystem. Samba receives the file from the PC
20 then passes the file to a external "print command". What print command
21 you use is up to you.
22
23 The whole things is controlled using options in smb.conf. The most
24 relevant options (which you should look up in the smb.conf man page)
25 are:
26       [global]
27         print command     - send a file to a spooler
28         lpq command       - get spool queue status
29         lprm command      - remove a job
30       [printers]
31         path = /var/spool/lpd/samba
32
33 The following are nice to know about:
34
35         queuepause command   - stop a printer or print queue
36         queueresume command  - start a printer or print queue
37
38 Example:
39         print command = /usr/bin/lpr -r -P%p %s
40         lpq command   = /usr/bin/lpq    -P%p %s
41         lprm command  = /usr/bin/lprm   -P%p %j
42         queuepause command = /usr/sbin/lpc -P%p stop
43         queuepause command = /usr/sbin/lpc -P%p start
44
45 Samba should set reasonable defaults for these depending on your
46 system type, but it isn't clairvoyant. It is not uncommon that you
47 have to tweak these for local conditions.  The commands should
48 always have fully specified pathnames,  as the smdb may not have
49 the correct PATH values.
50
51 When you send a job to Samba to be printed,  it will make a temporary
52 copy of it in the directory specified in the [printers] section.
53 and it should be periodically cleaned out.  The lpr -r option
54 requests that the temporary copy be removed after printing; If
55 printing fails then you might find leftover files in this directory,
56 and it should be periodically cleaned out.  Samba used the lpq
57 command to determine the "job number" assigned to your print job
58 by the spooler.
59
60 The %<letter> are "macros" that get dynamically replaced with appropriate
61 values when they are used. The %s gets replaced with the name of the spool
62 file that Samba creates and the %p gets replaced with the name of the
63 printer. The %j gets replaced with the "job number" which comes from
64 the lpq output.
65
66 DEBUGGING PRINTER PROBLEMS
67
68 One way to debug printing problems is to start by replacing these
69 command with shell scripts that record the arguments and the contents
70 of the print file. A simple example of this kind of things might
71 be:
72
73         print command = /tmp/saveprint %p %s
74
75     #!/bin/saveprint
76     # we make sure that we are the right user
77     /usr/bin/id -p >/tmp/tmp.print
78     # we run the command and save the error messages
79     # replace the command with the one appropriate for your system
80     /usr/bin/lpr -r -P$1 $2 2>>&/tmp/tmp.print
81
82 Then you print a file and try removing it.  You may find that the
83 print queue needs to be stopped in order to see the queue status
84 and remove the job:
85
86 h4: {42} % echo hi >/tmp/hi
87 h4: {43} % smbclient //localhost/lw4
88 added interface ip=10.0.0.4 bcast=10.0.0.255 nmask=255.255.255.0
89 Password: 
90 Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
91 smb: \> print /tmp/hi
92 putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
93 smb: \> queue
94 1049     3            hi-17534
95 smb: \> cancel 1049
96 Error cancelling job 1049 : code 0
97 smb: \> cancel 1049
98 Job 1049 cancelled
99 smb: \> queue
100 smb: \> exit
101
102 The 'code 0' indicates that the job was removed.  The comment
103 by the  smbclient is a bit misleading on this.
104 You can observe the command output and then and look at the
105 /tmp/tmp.print file to see what the results are.  You can quickly
106 find out if the problem is with your printing system.  Often people
107 have problems with their /etc/printcap file or permissions on
108 various print queues.
109
110 WHAT PRINTERS DO I HAVE
111
112 You can use the 'testprns' program to check to see if the printer
113 name you are using is recognized by Samba.  For example,  you can
114 use:
115
116     testprns printer /etc/printcap
117
118 Samba can get its printcap information from a file or from a program.
119 You can try the following to see the format of the extracted
120 information:
121
122     testprns -a printer /etc/printcap
123
124     testprns -a printer '|/bin/cat printcap'
125
126 SETTING UP PRINTCAP AND PRINT SERVERS
127
128 You may need to set up some printcaps for your Samba system to use.
129 It is strongly recommended that you use the facilities provided by
130 the print spooler to set up queues and printcap information.
131
132 Samba requires either a printcap or program to deliver printcap
133 information.  This printcap information has the format:
134
135   name|alias1|alias2...:option=value:...
136
137 For almost all printing systems, the printer 'name' must be composed
138 only of alphanumeric or underscore '_' characters.  Some systems also
139 allow hyphens ('-') as well.  An alias is an alternative name for the
140 printer,  and an alias with a space in it is used as a 'comment'
141 about the printer.  The printcap format optionally uses a \ at the end of lines
142 to extend the printcap to multiple lines.
143
144
145 Here are some examples of printcap files:
146
147 pr              just printer name
148 pr|alias        printer name and alias
149 pr|My Printer   printer name, alias used as comment
150 pr:sh:\        Same as pr:sh:cm= testing
151   :cm= \ 
152   testing
153 pr:sh           Same as pr:sh:cm= testing
154   :cm= testing
155
156 Samba reads the printcap information when first started.  If you make
157 changes in the printcap information, then you must do the following:
158
159 a)  make sure that the print spooler is aware of these changes.
160     The LPRng system uses the 'lpc reread' command to do this.
161
162 b)  make sure that the spool queues, etc., exist and have the
163     correct permissions.  The LPRng system uses the 'checkpc -f'
164     command to do this.
165
166 c)  You now should send a SIGHUP signal to the smbd server to have
167     it reread the printcap information.
168
169 JOB SENT, NO OUTPUT
170
171 This is the most frustrating part of printing.  You may have sent the
172 job,  verified that the job was forwarded,  set up a wrapper around
173 the command to send the file,  but there was no output from the printer.
174
175 First,  check to make sure that the job REALLY is getting to the
176 right print queue.  If you are using a BSD or LPRng print spooler,
177 you can temporarily stop the printing of jobs.  Jobs can still be
178 submitted, but they will not be printed.  Use:
179
180   lpc -Pprinter stop
181
182 Now submit a print job and then use 'lpq -Pprinter' to see if the
183 job is in the print queue.  If it is not in the print queue then
184 you will have to find out why it is not being accepted for printing.
185
186 Next, you may want to check to see what the format of the job really
187 was.  With the assistance of the system administrator you can view
188 the submitted jobs files.  You may be surprised to find that these
189 are not in what you would expect to call a printable format.
190 You can use the UNIX 'file' utitily to determine what the job
191 format actually is:
192
193     cd /var/spool/lpd/printer   # spool directory of print jobs
194     ls                          # find job files
195     file dfA001myhost
196
197 You should make sure that your printer supports this format OR that
198 your system administrator has installed a 'print filter' that will
199 convert the file to a format appropriate for your printer.
200
201 JOB SENT, STRANGE OUTPUT
202
203 Once you have the job printing, you can then start worrying about
204 making it print nicely.
205
206 The most common problem is extra pages of output: banner pages
207 OR blank pages at the end.
208
209 If you are getting banner pages,  check and make sure that the
210 printcap option or printer option is configured for no banners.
211 If you have a printcap,  this is the :sh (suppress header or banner
212 page) option.  You should have the following in your printer.
213
214    printer: ... :sh
215
216 If you have this option and are still getting banner pages,  there
217 is a strong chance that your printer is generating them for you
218 automatically.  You should make sure that banner printing is disabled
219 for the printer.  This usually requires using the printer setup software
220 or procedures supplied by the printer manufacturer.
221
222 If you get an extra page of output,  this could be due to problems
223 with your job format,  or if you are generating PostScript jobs,
224 incorrect setting on your printer driver on the MicroSoft client.
225 For example, under Win95 there is a option:
226
227   Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|
228
229 that allows you to choose if a Ctrl-D is appended to all jobs.
230 This is a very bad thing to do, as most spooling systems will
231 automatically add a ^D to the end of the job if it is detected as
232 PostScript.  The multiple ^D may cause an additional page of output.
233
234 RAW POSTSCRIPT PRINTED
235
236 This is a problem that is usually caused by either the print spooling
237 system putting information at the start of the print job that makes
238 the printer think the job is a text file, or your printer simply
239 does not support PostScript.  You may need to enable 'Automatic
240 Format Detection' on your printer.
241
242 ADVANCED PRINTING
243
244 Note that you can do some pretty magic things by using your
245 imagination with the "print command" option and some shell scripts.
246 Doing print accounting is easy by passing the %U option to a print
247 command shell script. You could even make the print command detect
248 the type of output and its size and send it to an appropriate
249 printer.
250
251 DEBUGGING
252
253 If the above debug tips don't help, then maybe you need to bring in
254 the bug guns, system tracing. See Tracing.txt in this directory.
255 -----------------------------------------------------------------------------