Unix Power ToolsUnix Power ToolsSearch this book

47.5. Printing with Samba

Sharing Unix printers with a SMB network is pretty straightforward. You can use swat to select the printer you want to share. If your /etc/printcap is configured correctly, swat will allow you to select one of those printers from a drop-down menu. You will then be able to set access controls over that printer, as well as make the printer browsable. Be sure to click the Commit Changes button when you're finished to save your settings. If you're running the SMB daemons as standalone processes, you can restart them from the status section of swat. In any case, your printers won't be shared until the daemons are restarted.

Of course, you can also edit the smb.conf file directly. Here's how to share your default printer with the SMB network:

[lp]
        printable = Yes
        printer name = lp
        ; printing = BSD
        ; print command = /usr/bin/lpr -r %s
        path = /var/spool/samba
        guest ok = Yes
        read only = No
        comment = hp

The block should start off with the lpr queue name. The most important directive for print shares is printable, which identifies this block as defining a print share. The printer name needs to match the Unix printer queue name for the printer you wish to share. If you have defined a global directive printing (which defaults to BSD style print queues), you don't need to worry about explicitly telling Samba how to print to the queue. In the commented-out print command directive, the %s stands for the file you wish to print. The path directive defines the samba print spool directory. This directory needs to be writable by the smbd process. Both guest ok and read only directives are simple access controls. The comment block is self-explanatory.

After saving your changes and restarting the Samba servers (if needed), your shares should be browsable by the SMB network. From Unix, you can print to SMB printers with the following command:

$ smbclient //netbios-name/printer
smb: \> print filename-to-print

Here the smbclient program (described in more detail below) is used to connect to the SMB printer. Using the interactive shell, the print command will send any file you specify to the printer. On some systems, you may find a program called smbprint that is a Bourne shell wrapper around smbclient.

-- JJ



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.