Added in oplock info.
[kai/samba.git] / docs / textdocs / Printing.txt
1 Contributor:    Unknown <samba-bugs@samba.anu.edu.au>
2 Date:           Unknown
3 Status:         Current
4
5 Subject:        Dubugging Printing Problems
6 =============================================================================
7
8 This is a short description of how to debug printing problems with
9 Samba. This describes how to debug problems with printing from a SMB
10 client to a Samba server, not the other way around. For the reverse
11 see the examples/printing directory.
12
13 Please send enhancements to this file to samba-bugs@samba.anu.edu.au
14
15 Ok, so you want to print to a Samba server from your PC. The first
16 thing you need to understand is that Samba does not actually do any
17 printing itself, it just acts as a middleman between your PC client
18 and your Unix printing subsystem. Samba receives the file from the PC
19 then passes the file to a external "print command". What print command
20 you use is up to you.
21
22 The whole things is controlled using options in smb.conf. The most
23 relevant options (which you should look up in the smb.conf man page)
24 are:
25         print command
26         lpq command
27         lprm command
28
29 Samba should set reasonable defaults for these depending on your
30 system type, but it isn't clairvoyant. It is not uncommon that you
31 have to tweak these for local conditions.
32
33 On my system I use the following settings:
34
35         print command = lpr -r -P%p %s
36         lpq command = lpq -P%p
37         lprm command = lprm -P%p %j
38
39 The % bits are "macros" that get dynamically replaced with variables
40 when they are used. The %s gets replaced with the name of the spool
41 file that Samba creates and the %p gets replaced with the name of the
42 printer. The %j gets replaced with the "job number" which comes from
43 the lpq output.
44
45 When I'm debugging printing problems I often replace these command
46 with pointers to shell scripts that record the arguments, and the
47 contents of the print file. A simple example of this kind of things
48 might be:
49
50         print command = cp %s /tmp/tmp.print
51
52 then you print a file and look at the /tmp/tmp.print file to see what
53 is produced. Try printing this file with lpr. Does it work? If not
54 then your problem with with your lpr system, not with Samba. Often
55 people have problems with their /etc/printcap file or permissions on
56 various print queues. 
57
58 Another common problem is that /dev/null is not world writeable. Yes,
59 amazing as it may seem, some systems make /dev/null only writeable by
60 root. Samba uses /dev/null as a place to discard output from external
61 commands like the "print command" so if /dev/null is not writeable
62 then nothing will work.
63
64 Other really common problems:
65
66 - lpr isn't in the search path when Samba tries to run it. Fix this by
67 using the full path name in the "print command"
68
69 - the user that the PC is trying to print as doesn't have permission
70 to print. Fix your lpr system.
71
72 - you get an extra blank page of output. Fix this in your lpr system,
73 probably by editing /etc/printcap. It could also be caused by
74 incorrect setting on your client. For example, under Win95 there is a
75 option Printers|Printer Name|(Right
76 Click)Properties|Postscript|Advanced| that allows you to choose if a
77 Ctrl-D is appended to all jobs. This will affect if a blank page is
78 output. 
79
80 - you get raw postscript instead of nice graphics on the output. Fix
81 this either by using a "print command" that cleans up the file before
82 sending it to lpr or by using the "postscript" option in smb.conf.
83
84 Note that you can do some pretty magic things by using your
85 imagination with the "print command" option and some shell
86 scripts. Doing print accounting is easy by passing the %U option to a
87 print command shell script. You could even make the print command
88 detect the type of output and its size and send it to an appropriate
89 printer. 
90
91 If the above debug tips don't help, then maybe you need to bring in
92 the bug gun, system tracing. See Tracing.txt in this directory.
93