摘自:http://www.samba.org/samba/docs/using_samba/ch10.html
Samba Printing Options
Table 10-2 summarizes the Samba printingoptions.
Table 10-2. Printing configuration options
Option | Parameters | Function | Default | Scope |
---|---|---|---|---|
printing | bsd, sysv,cups, hpux,aix, qnx,plp, softq, orlprng | Printing system type of the Samba host | System-dependent | Share |
printable (print ok) | boolean | Marks a share as a printing share | no | Share |
printer (printer name) | string (Unix printer name) | Name for the printer that is shown to clients | System-dependent | Share |
lpq cache time | numeric (time in seconds) | Amount of time in seconds that Samba will cache the printer queuestatus | 10 | Global |
postscript | boolean | Treats all print jobs as PostScript by prefixing%! at the beginning of each file | no | Share |
load printers | boolean | If yes, automatically loads each printer in theprintcap file as printing shares | yes | Global |
print command | string (shell command) | Unix command to perform printing | See below | Share |
lpq command | string (shell command) | Unix command to return the status of the printing queue | See below | Share |
lprm command | string (shell command) | Unix command to remove a job from the printing queue | See below | Share |
lppause command | string (shell command) | Unix command to pause a job on the printing queue | See below | Share |
lpresume command | string (shell command) | Unix command to resume a paused job on the printing queue | See below | Share |
printcap name (printcap) | string (filename) | Location of the printer capabilities file | System-dependent | Global |
min print space | numeric (size in kilobytes) | Minimum amount of free disk space that must be present to print | 0 | Share |
queuepause command | string (shell command) | Unix command to pause a queue | See below | Share |
queueresume command | string (shell command) | Unix command to resume a queue | See below | Share |
printing
The printing configuration option tellsSamba which printing system to use. There areseveral different families of commands to control printing and printstatusing. Samba supports seven different types, as shown in Table 10-3.
Table 10-3. Printing system types
Variable | Definition |
---|---|
BSD | Berkeley Unix system |
SYSV | System V |
CUPS | Common Unix Printing System |
AIX | IBM's AIX operating system |
HPUX | Hewlett-Packard Unix |
QNX | QNX Realtime Operating System |
LPRNG | LPR Next Generation |
SOFTQ | SOFTQ system |
PLP | Portable Line Printer |
The value for this option must be one of these seven selections. Forexample:
printing = SYSV
The default value of this option is system-dependent and isconfigured when Samba is first compiled. For most systems, theconfigure script automatically detects theprinting system to be used and configures it properly in the Sambamakefile. However, if your system is a PLP, LPRNG, or QNX printingsystem, you need to specify this explicitly in the makefile or theprinting share.
The most common system types are BSD, SYSV, and CUPS. Each printer ona BSD Unix server is described in the printer capabilitiesfile—normally /etc/printcap. See thesection on the printcap fileparameter for more information on this topic.
Setting the printing configuration optionautomatically sets at least three other printing options for theservice in question: printcommand, lpqcommand, and lprmcommand. If you are running Samba on a system thatdoesn't support any of the printing styles listed inTable 10-3, simply set the commands for each ofthese manually.
printable
The printable option must be set toyes to flag a share as a printing service. If thisoption is not set, the share will be treated as a disk share instead.You can set the option as follows:
[printer1] printable = yes
printer
The option, also calledprinter name,specifies the name of the printer on the server to which the sharepoints. This option has no default and should be set explicitly inthe configuration file, even though Unix systems themselves oftenrecognize a default name such as lp for a printer.For example:
[deskjet] printer = hpdkjet1
lpq cache time
The global lpq cachetime option allows you to set the number ofseconds for which Samba will remember the current printer status.After this time elapses, Samba will issue an lpqcommand (or whatever command you specify with thelpq command option) to get amore up-to-date status that it can report to users. This defaults to10 seconds, but can be increased if your lpqcommand takes an unusually long time to run or youhave lots of clients. A time setting of 0 disables caching of queuestatus. The following example resets the time to 30 seconds:
[deskjet] lpq cache time = 30
postscript
The postscript option forces theprinter to treat all data sent to it as PostScript. It does this byprefixing the characters %! to the beginning ofthe first line of each job. It is normally used with PCs that inserta ^D (control-D or"end-of-file" mark) in front of thefirst line of a PostScript file. It will not, obviously, turn anon-PostScript printer into a PostScript one. The default value ofthis options is no. You can override it asfollows:
[deskjet] postscript = yes
load printers
The load printersoption tells Samba to create shares for all known printer names andload those shares into the browse list. Samba will create and list aprinter share for each printer name in/etc/printcap (or the system equivalent). Forexample, if yourprintcap file lookslike this:[3]
lp:\ :sd=/var/spool/lpd/lp:\ spool directory :mx#0:\ maximum file size (none) :sh:\ supress burst header (no) :lp=/dev/lp1:\ device name for output :if=/var/spool/lpd/lp/filter: text filter laser:\ :sd=/var/spool/lpd/laser:\ spool directory :mx#0:\ maximum file size (none) :sh:\ supress burst header (no) :lp=/dev/laser:\ device name for output :if=/var/spool/lpd/lp/filter: text filter
the shares [lp] and [laser] areautomatically created as valid print shares when Samba is started.Both shares borrow the configuration options specified in the[printers] section to configure themselves and areavailable in the browse list for the Samba server. The default valuefor this option is yes. If you prefer to specifyeach printer explicitly in your configuration file, use thefollowing:
[global] load printers = no
print command, lpq command, lprm command,lppause command, lpresume command
These options tell Samba which Unix commands control and send data tothe printer. The Unix commands involved are: lpr(send to Line PRinter), lpq (List PrinterQueue), lprm (Line Printer ReMove), andoptionally lppause andlpresume. Samba provides an option named aftereach command, in case you need to override any of the systemdefaults. For example, consider the following:
lpq command = /usr/ucb/lpq %p
This would set lpq command touse /usr/ucb/lpq. Similarly:
lprm command = /usr/local/bin/lprm -P%p %j
would set the Samba printer remove command to/usr/local/bin/lprm and provide it the print jobnumber using the %j variable.
The default values for each option are dependent on the value of theprinting option. Table 10-4shows the default commands for each printing option. The most popularprinting system is BSD.
Table 10-4. Default commands for various printing options
Option | BSD, AIX, PLP, LPRNG | SYSV, HPUX | QNX | SOFTQ |
---|---|---|---|---|
print command | lpr -r -P%p %s | lp -c -d%p %s; rm %s | lp -r -P%p %s | lp -d%p -s %s; rm %s |
lpq command | lpq -P%p | lpstat -o%p | lpq -P%p | lpstat -o%p |
lprm command | lprm -P%p %j | cancel %p-%j | cancel %p-%j | cancel %p-%j |
lppause command | lp -i %p-%j -H hold (SYSV only) | None | None | None |
lpresume command | lp -i %p-%j -H resume (SYSV only) | None | None | qstat -s -j%j -r |
It is usually unnecessary to reset these options in Samba, with thepossible exception of the printcommand. This option might need to be setexplicitly if your printing system doesn't have a-r (remove after printing) option on theprinting command. For example:
print command = /usr/local/lpr -P%p %s; /bin/rm %s
With a bit of judicious programming, thesesmb.conf options can also be used for debugging:
print command = cat %s >>/tmp/printlog; lpr -r -P%p %s
Using the previous configuration, it is possible to verify that filesare actually being delivered to the Samba server. If they are, theircontents will show up in the file /tmp/printlog.
After BSD, the next most popular kind of printing system is SYSV (orSystem V) printing, plus some SYSV variants forIBM's AIX and Hewlett-Packard'sHP-UX. These systems do not have an/etc/printcap file. Instead, theprintcap file option can be setto an appropriate lpstat command for the system.This tells Samba to get a list of printers from thelpstat command. Alternatively, you can set theglobal configuration option printcapname to the name of a dummyprintcap file you provide. In the latter case,the file must contain a series of lines such as:
lp|print1|My Printer 1 print2|My Printer 2 print3|My Printer 3
Each line names a printer followed by aliases for it. In thisexample, the first printer is called lp,print1, or MyPrinter 1, whichever the userprefers to use. The first name is used in place of%p in any command Samba executes for that printer.
Two additional printer types are also supported by Samba: LPRNG (LPRNew Generation) and PLP (Public Line Printer). These are publicdomain and open source printing systems and are used by many sites toovercome problems with vendor-supplied software. Samba also supportsthe printing systems of the SOFTQ and QNX real-time operatingsystems.
printcap name
If the printcapname option (also calledprintcap) appears in a printing share, Samba usesthe file specified as the system printer capabilities file (normally/etc/printcap). However, you can reset it to afile consisting of only the printers you want to share over thenetwork. The value must be the filename (with its complete pathspecified) of a printer capabilities file on the server:
[deskjet] printcap name = /usr/local/samba/lib/printcap
The CUPS printing system uses its own method of determining printercapabilities, rather than the standard printcapfile. In this case, set printcapname as follows:
[global] printing = cups printcap name = cups
min print space
The min printspace option sets the amount of space that must beavailable on the disk that contains the spool directory if printingis to be allowed. Setting it to zero (the default) turns the checkoff; setting it to any other number sets the amount of free space inkilobytes required. This option helps to avoid having print jobs fillup the remaining disk space on the server, which can cause otherprocesses to fail:
[deskjet] min print space = 4000
queuepause command
This configuration option specifies a command that tells Samba how topause an entire print queue, as opposed to a single job on the queue.The default value depends on the printing type chosen. You should notneed to alter this option.