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