| 1 |
<samba:parameter name="print command" |
| 2 |
context="S" |
| 3 |
type="string" |
| 4 |
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> |
| 5 |
<description> |
| 6 |
<para>After a print job has finished spooling to |
| 7 |
a service, this command will be used via a <command moreinfo="none">system()</command> |
| 8 |
call to process the spool file. Typically the command specified will |
| 9 |
submit the spool file to the host's printing subsystem, but there |
| 10 |
is no requirement that this be the case. The server will not remove |
| 11 |
the spool file, so whatever command you specify should remove the |
| 12 |
spool file when it has been processed, otherwise you will need to |
| 13 |
manually remove old spool files.</para> |
| 14 |
|
| 15 |
<para>The print command is simply a text string. It will be used |
| 16 |
verbatim after macro substitutions have been made:</para> |
| 17 |
|
| 18 |
<para>%s, %f - the path to the spool |
| 19 |
file name</para> |
| 20 |
|
| 21 |
<para>%p - the appropriate printer |
| 22 |
name</para> |
| 23 |
|
| 24 |
<para>%J - the job name as transmitted by the client, |
| 25 |
but with dangerous characters being replaced by _. |
| 26 |
You should use single quotes (directly) around %J, e.g. '%J', |
| 27 |
see CVE-2026-4480 for more details. |
| 28 |
</para> |
| 29 |
|
| 30 |
<para>%c - The number of printed pages |
| 31 |
of the spooled job (if known).</para> |
| 32 |
|
| 33 |
<para>%z - the size of the spooled |
| 34 |
print job (in bytes)</para> |
| 35 |
|
| 36 |
<para>The print command <emphasis>MUST</emphasis> contain at least |
| 37 |
one occurrence of <parameter moreinfo="none">%s</parameter> or <parameter moreinfo="none">%f |
| 38 |
</parameter> - the <parameter moreinfo="none">%p</parameter> is optional. At the time |
| 39 |
a job is submitted, if no printer name is supplied the <parameter moreinfo="none">%p |
| 40 |
</parameter> will be silently removed from the printer command.</para> |
| 41 |
|
| 42 |
<para>If specified in the [global] section, the print command given |
| 43 |
will be used for any printable service that does not have its own |
| 44 |
print command specified.</para> |
| 45 |
|
| 46 |
<para>If there is neither a specified print command for a |
| 47 |
printable service nor a global print command, spool files will |
| 48 |
be created but not processed and (most importantly) not removed.</para> |
| 49 |
|
| 50 |
<para>Note that printing may fail on some UNIXes from the |
| 51 |
<constant>nobody</constant> account. If this happens then create |
| 52 |
an alternative guest account that can print and set the <smbconfoption name="guest account"/> |
| 53 |
in the [global] section.</para> |
| 54 |
|
| 55 |
<para>You can form quite complex print commands by realizing |
| 56 |
that they are just passed to a shell. For example the following |
| 57 |
will log a print job, print the file, then remove it. Note that |
| 58 |
';' is the usual separator for command in shell scripts.</para> |
| 59 |
|
| 60 |
<para><command moreinfo="none">print command = echo Printing %s >> |
| 61 |
/tmp/print.log; lpr -P %p %s; rm %s</command></para> |
| 62 |
|
| 63 |
<para>You may have to vary this command considerably depending |
| 64 |
on how you normally print files on your system. The default for |
| 65 |
the parameter varies depending on the setting of the <smbconfoption name="printing"/> |
| 66 |
parameter.</para> |
| 67 |
|
| 68 |
<para>Default: For <command moreinfo="none">printing = BSD, AIX, QNX, LPRNG |
| 69 |
or PLP :</command></para> |
| 70 |
<para><command moreinfo="none">print command = lpr -r -P%p %s</command></para> |
| 71 |
|
| 72 |
<para>For <command moreinfo="none">printing = SYSV or HPUX :</command></para> |
| 73 |
<para><command moreinfo="none">print command = lp -c -d%p %s; rm %s</command></para> |
| 74 |
|
| 75 |
<para>For <command moreinfo="none">printing = SOFTQ :</command></para> |
| 76 |
<para><command moreinfo="none">print command = lp -d%p -s %s; rm %s</command></para> |
| 77 |
|
| 78 |
<para>For printing = CUPS : If SAMBA is compiled against |
| 79 |
libcups, then <smbconfoption name="printcap">cups</smbconfoption> |
| 80 |
uses the CUPS API to |
| 81 |
submit jobs, etc. Otherwise it maps to the System V |
| 82 |
commands with the -oraw option for printing, i.e. it |
| 83 |
uses <command moreinfo="none">lp -c -d%p -oraw; rm %s</command>. |
| 84 |
With <command moreinfo="none">printing = cups</command>, |
| 85 |
and if SAMBA is compiled against libcups, any manually |
| 86 |
set print command will be ignored.</para> |
| 87 |
</description> |
| 88 |
|
| 89 |
<value type="example">/usr/local/samba/bin/myprintscript %p %s</value> |
| 90 |
</samba:parameter> |