/etc/printcap: # # Set the environment variable PRINTER to either # PRINTER=eng or PRINTER=colour or PRINTER=optrac or PRINTER=optrar # if you want to use the lpr command by itself. Alternatively, you # can say lpr -PSteps:to print your file. # Harish Pillay (h.pillay@ieee.org) # //gaia/lexENG1 via smbprint # eng|lp:\ :cm=LexMark Optra R+ PostScript Printer:\ :lp=/dev/eng:\ :sd=/var/spool/lpd/eng:\ :af=/var/spool/lpd/eng/acct:\ :mx#0:\ :if=/usr/local/samba/bin/smbprint: # # //gaia/lexTRG1 via smbprint # colour|lpcolour:\ :cm=LexMark Optra C PostScript Printer:\ :lp=/dev/colour:\ :sd=/var/spool/lpd/colour:\ :af=/var/spool/lpd/colour/acct:\ :mx#0:\ :if=/usr/local/samba/bin/smbprint: # # using lpr directly to Optra R+ Postscript (B&W) # optrar:\ :cm=LexMark Optra R+ PostScript Printer:\ :sd=/usr/spool/lpd:\ :lf=/usr/spool/lpd/errors:\ :rp=optrar.dom.ain:\ :rm=optrar.dom.ain:\ :sh:\ :sf: # # using lpr directly to Optra C Postscript (Colour) # optrac:\ :cm=LexMark Optra C PostScript Printer:\ :sd=/usr/spool/lpd:\ :lf=/usr/spool/lpd/errors:\ :rp=optrac.dom.ain:\ :rm=optrac.dom.ain:\ :sh:\ :sf: #end of /etc/printcap file
/usr/local/samba/bin/smbprint:
#!/bin/sh -x
# This script is an input filter for printcap printing on a unix machine. It
# uses the smbclient program to print the file to the specified smb-based
# server and service.
# For example you could have a printcap entry like this
#
# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
#
# which would create a unix printer called "smb" that will print via this
# script. You will need to create the spool directory /usr/spool/smb with
# appropriate permissions and ownerships for your system.
#
# Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
# so that the server, service, and password can be read from
# a /usr/var/spool/lpd/PRINTNAME/.config file.
#
# Script further modified to add user variable by h.pillay@ieee.org (Harish Pillay)
#
# In order for this to work the /etc/printcap entry must include an
# accounting file (af=...):
#
# cdcolour:\
# :cm=CD IBM Colorjet on 6th:\
# :sd=/var/spool/lpd/cdcolour:\
# :af=/var/spool/lpd/cdcolour/acct:\
# :if=/usr/local/etc/smbprint:\
# :mx=0:\
# :lp=/dev/null:
#
# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
# server=PC_SERVER
# service=PR_SHARENAME
# password="password"
# user=USERNAME (added by h.pillay@ieee.org)
#
# E.g.
# server=PAULS_PC
# service=CJET_371
# password=""
# user=HARISH (added by h.pillay@ieee.org)
#
# Debugging log file, change to /dev/null if you like.
#
logfile=/tmp/smb-print.log
# logfile=/dev/null
#
# The last parameter to the filter is the accounting file name.
# Extract the directory name from the file name.
# Concat this with /.config to get the config file.
#
eval acct_file=\$$#
spool_dir=`dirname $acct_file`
config_file=$spool_dir/.config
# Should read the following variables set in the config file:
# server
# service
# password
# user (added by h.pillay@ieee.org)
eval `cat $config_file`
#
# Some debugging help, change the >> to > if you want to same space.
#
echo "server $server, service $service" >> $logfile
(
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
echo translate
echo "print -"
cat
) | /usr/local/samba/bin/smbclient "\\\\$server\\$service" $password -U $user -N -P >> $logfile
#end of /usr/local/samba/bin/smbprint
Good tip sheet. I use something very similar. One helpful tip, this is not
a particularly good idea:
:lp=/dev/null:\
lpr does an 'exclusive' open on the file you specify as lp=. It does this in
order to prevent multiple processes from trying to print to the dame printer
at the same time.
The side effect of this is that in your case, eng and colour can't print at
the same time, (usually more or less transparent since they probably print
quickly and since they queue you probably don't notice) but any other process
that tries to write to /dev/null will break!
On a single user system, probably not a big problem. I have a system with
over 50 printers. It would be a problem there.
The solution is to create a dummy printer for each. Eg: touch /dev/eng.
I have modified the lp entries in the printcap file above to take into
account Rick's suggestion. I did the following:
#touch /dev/eng #touch /dev/colourThanks Rick for the tip from the battlefield!