Accessing Shared Printers with smbprint

Accessing Shared Printers with smbprint

Using a Windows printer from Linux is very simple. Aside from a little configuration, the only thing you need is the smbprint utility. Samba also provides the smbspool utility, which performs almost exactly the same task as smbprint. However, the command line argument positions are arranged so that it can be used as a spooler under the Common Unix Printing System. We will discuss only smbprint in this section.

To set up a Windows printer, you first need to create an SMB-specific configuration file. The recommended location is a directory $SPOOL_DIR/lpd/<printer- name >, where $SPOOL_DIR is the standard spool directory on your system. For example, on a Debian system the path is /var/spool. Create this directory, and then create a file containing the print server name, share name, and password (if necessary). Save this file in the new directory, with the name .config. On my Linux machine, for example, I have set up a Canon BJ-200 as a remote printer:

  $ cat /var/spool/lpd/canon/.config  
  server=KEARNEY  
  service=CANON  
  password=""  

Now you can send a print job to the remote printer by running the smbprint command:

  $ smbprint /var/spool/lpd/canon/acct < print.job  

The first argument is the name of the accounting file where lpd should log the print job. This file does not have to exist yet, but it should be in the right spool subdirectory. smbprint assumes its configuration file is in the same directory as this accounting file. The second argument is a file containing the print job, formatted in the appropriate printer-control language. If you're unlucky enough to have a printer that doesn't understand PostScript, you may have to use Ghostscript (gs) to convert a PostScript file to a particular printer language. In the case of my Canon bubble jet printer, I have to use the bj200 driver, resulting in the following com mand line:

  $ cat myfile.ps  gs -q -dSAFER -sDEVICE=bj200 -dQuality=1 -dNOPAUSE \  
  -sOutputFile=- -  smbprint /var/spool/lpd/canon/acct  

On my machine, I placed this command line in a shell script so that I just have to redirect a PostScript document into the command in order to print it remotely.

The final step is to integrate calls to this script into whichever print architecture you prefer. If you use lpd/lprng, for example, you'll want to modify your /etc/printcap entry to add this script as an output filter:

  # /etc/printcap: printer capability database. See printcap(5).  
  # You can use the filter entries df, tf, cf, gf, etc. for  
  # your own filters. See /etc/filter.ps, /etc/filter.pcl, and  
  # the printcap(5) manual page for further details.  
   
  canonCanon BJ-200 on Kearney:\  
   :sd=/var/spool/lpd/canon:\ 
 :af=/var/spool/lpd/canon/acct:\ 
  :mx#0:\  
  :sh:\  
  :of=/etc/printing/canon.filter:  

 



Multitool Linux. Practical Uses for Open Source Software
Multitool Linux: Practical Uses for Open Source Software
ISBN: 0201734206
EAN: 2147483647
Year: 2002
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net