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