To share a Linux printer with Windows machines, you need to make certain that your printer is set up to work under Linux. If you can print from Linux, setting up an SMB share of the printer is stright forward.
See the Printing HOWTO to set up local printing.
Since the author used a printer connected to a Windows NT machine (a long time ago - before converting our network nearly totally to Linux), this section should not be taken as definitive, but merely a suggestion. Anyone with details to share, please send them to dwood@plugged.net.au so this section can be completed.
Add printing configuration to your smb.conf:
[global]
printing = bsd
printcap name = /etc/printcap
load printers = yes
log file = /var/log/samba-log.%m
lock directory = /var/lock/samba
[printers]
comment = All Printers
security = server
path = /var/spool/lpd/lp
browseable = no
printable = yes
public = yes
writable = no
create mode = 0700
[ljet]
security = server
path = /var/spool/lpd/lp
printer name = lp
writable = yes
public = yes
printable = yes
print command = lpr -r -h -P %p %s
Make certain that the printer path (in this case under [ljet]) matches the spool directory in /etc/printcap!
The lines:
printcap name = /etc/printcap load printers = yes
controls whether all the printers in /etc/printcap should be loaded by default. If you do this, there is no reason to set up printers individually. The section [printers] specifies options for the printers that you wish to explicitly difine. If the printing subsystem you are using doesn't work this way (BSD), you need to set up a fake printcap file (or to use the 'print command' technique, see below). For more information on the printcap system see the Printing HOWTO.
A useful technique to test the network connection is to change the print command to:
print command = cp %S /tmp/print.%P.%S
The resulting file can then be analyzed.
NOTE: There are some problems sharing printers on UNIX boxes with Windows NT machines using Samba. One problem is with NT seeing the shared printer properly. To fix this, see the notes in the Samba distribution in the file docs/WinNT.txt. The other deals with password problems. See the comments in the same file for an annoying gain of understanding and failure to fix the problem.
Oleg L. Machulskiy ( machulsk@shade.msu.ru) suggests that a better print command to use in the above example would be:
print command = smb2ps %s | lpr -r -h -P %p
where 'smb2ps' is a script which transforms the spool file received from Windows into usual a usable Postscript file. It must cut off first 3 lines and last 2 lines, because these lines contain some PJL or PCL codes.
That approach is only needed if your Windows machine is printing PCL and not real Postscript. I have found that Windows 95/98/NT don't have a generic Postscript driver per se, but the "Digital turbo Printserver 20" driver acts as a good general Postscript driver for most setups. I have also heard that the "Apple LaserWriter II NTX" driver works for this purpose.
Jeff Stern ( jstern@eclectic.ss.uci.edu) reported the following that may be of help to some of you:
--------------------------%<---------------------------------- Problem I was having was that I could print via lpd/lpr to my Linux printer, from the Linux box itself. But I couldn't get it to print from a remote Win95 machine. When I tried
smbclient \\eclectic\belen -P
and then tried to
print myfile
I got errors about access denied. SO I reset the permissions on my /var/spool/lpd/lp1 directory to 777. I'm sorry, but that's what I had to do. I suppose alternatively I could have message with putting everyone on the Linux box in the 'lp' group, or made the directory be owned by the group 'users', etc.. But for now, this works (with ownership root:lp).
Finally, the other thing administrators should know is that the name of the account on the WIndows machine (which is trying to use the Linux printer via Samba) should have an equivalently-named account on the Linux box. Thus, if there is a user named 'joe' on the Windows machine, 'mywinbox' trying to print to the printer belen on Linux machine eclectic (\\eclectic\belen) then there should be a user named 'joe' on the Linux box. Then 'joe's login password will be the password to access eclectic's belen printer. This password will be asked for on the Windows machine when setting up the printer on the Windows box with Printers|Add Printer.
I kind of thought maybe this wouldn't be the case, since I have set up my printer to be 'public' in the smb.conf. But apparently it still asks for password. (The windows box unfortunately doesn't give you the opportunity to supply a different user name to the remote (Linux) printer. It just uses your local user name which you signed in as when you started up Win95. --------------------------%<----------------------------------
Dr. Michael Langner ( langner@fiz-chemie.de points out that write permission problems on the /var/spool/lpd/ tree could be avoided by use something like "path = /tmp" and "print command = lpr -r -P%p %s" instead.
Sometimes, a Postscript parsing error will occur with Postscript printing from Windows machines that causes an extra page to be printed at the end of every print job. The last page will always have "%%[ Lastpage ]%%" at the top of it. This seems to happen with Windows 95 and 98 only and is because the Postscript is malformed.
One way to handle that is to use a script to remove that bit of bad Postscript from the spooled jobs. Another way is to try to find a better Windows Postscript driver. Probably the best way is to us LPRng instead of Postscript to print to a Samba server.
Erik Ratcliffe ( erik@caldera.com) Caldera tells me that using LPRng means that any printer driver can be used from Windows machines. On the Samba server, they used an /etc/printcap entry that looked like this:
raw:\
:rw:sh:
:lp=/dev/lp1
:sd=/var/spool/lpd/raw
:fx=flp
LPRng doesn't require :\ at the end of every line. A printer entry will still need to be made in /etc/smb.conf for the physical printer. The print command line needs to use the "raw" entry in /etc/printcap and data must be sent to the printer in binary form. Try a print command line like this:
print command = lpr -b -Praw %s
You may also need to set the spooling on the Windows95 end to print directly to the printer instead of spooling.