Unix Power ToolsUnix Power ToolsSearch this book

45.9. Printing Over Samba

Samba provides SMB networking to Unix boxes; in English, that means it allows Unix machines to share disks and printers with Windows machines and vice versa. Chapter 49 details Samba; here we'll talk a bit about tricks for printing over Samba, since it's so useful and parts of it are fairly arcane.

45.9.1. Printing to Unix Printers from Windows

This is the easy one. Simply configure your printer normally using printcap, then set this in your smb.conf:

    load printers = yes

This tells Samba to read the printcap file and allow printing to any printer defined there. The default [printers] section automatically advertises all printers found and allows anyone with a valid login to print to them. You may want to make them browsable or printable by guest if you're not particularly worried about security on your network. Some Windows configurations will need guest access to browse, since they use a guest login to browse rather than your normal one; if you can't browse your Samba printers from your Windows client, try setting up guest access and see if that fixes it.

If you want to get really fancy, current versions of Samba can support downloading printer drivers to clients, just like Windows printer servers do. Take a look at the PRINTER_DRIVER2.txt file in the Samba distribution for more about how to do this.

45.9.2. Printing to Windows Printers from Unix

This one's a little more tricky. lpd doesn't know how to print to a Windows printer directly, or how to talk to Samba. However, lpd does know how to run files through a filter (Section 45.17). So what we'll do is provide a filter that hands the file to Samba, and then send the print job right to /dev/null:

laserjet:remote SMB laserjet via Samba\
    :lp=/dev/null:\
    :sd=/var/spool/lpd/laser:\
    :if=/usr/local/samba/bin/smbprint:

Samba comes with a sample filter called smbprint; it's often installed in an examples directory and will need to be moved to somewhere useful before setting this up. smbprint does exactly what we want; it takes the file and uses smbclient to send it to the right printer.

How does smbprint know which printer to send it to? It uses a file called .config in the given spool directory, which looks something like this:

server=WINDOWS_SERVER
service=PRINTER_SHARENAME
password="password"

The smbprint script is reasonably well documented in its comments. Look through it and tweak it to fit your own needs.

-- DJPH



Library Navigation Links

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