2 # This script is an input filter for printcap printing on a unix machine. It
3 # uses the smbclient program to print the file to the specified smb-based
5 # For example you could have a printcap entry like this
7 # smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
9 # which would create a unix printer called "smb" that will print via this
10 # script. You will need to create the spool directory /usr/spool/smb with
11 # appropriate permissions and ownerships for your system.
13 # Set these to the server and service you wish to print to
14 # In this example I have a WfWg PC called "lapland" that has a printer
15 # exported called "printer" with no password.
18 # Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
19 # so that the server, service, and password can be read from
20 # a /usr/var/spool/lpd/PRINTNAME/.config file.
22 # In order for this to work the /etc/printcap entry must include an
23 # accounting file (af=...):
26 # :cm=CD IBM Colorjet on 6th:\
27 # :sd=/var/spool/lpd/cdcolour:\
28 # :af=/var/spool/lpd/cdcolour/acct:\
29 # :if=/usr/local/etc/smbprint:\
33 # The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
38 # Please, do not modify the order in the file.
40 # share=\\server\deskjet
45 # The last parameter to the filter is the accounting file name.
46 # Extract the directory name from the file name.
47 # Concat this with /.config to get the config file.
50 spool_dir
=`dirname $acct_file`
51 config_file
=$spool_dir/.config
53 # Should read the following variables set in the config file:
59 eval `cat $config_file`
61 share
=`echo $share | sed "s/[\]/\//g"`
63 if [ "$user" != "" ]; then
69 if [ "$workgroup" != "" ]; then
75 if [ "$translate" = "yes" ]; then
76 command="translate ; print -"
80 #echo $share $password $translate $x_command > /tmp/smbprint.log
82 cat |
/usr
/bin
/smbclient
"$share" "$password" -E ${hostip:+-I} \
83 $hostip -N -P $usercmd "$user" $workgroupcmd "$workgroup" \
84 -c "$command" 2>/dev
/null