--- samba-pre2.0.7/packaging/RedHat/smbprint.foo Mon Nov 16 13:44:11 1998 +++ samba-pre2.0.7/packaging/RedHat/smbprint Tue Feb 1 23:04:21 2000 @@ -1,5 +1,4 @@ #!/bin/sh - # 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. @@ -18,7 +17,7 @@ # # Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton) # so that the server, service, and password can be read from -# a /var/spool/lpd/PRINTNAME/.config file. +# a /usr/var/spool/lpd/PRINTNAME/.config file. # # In order for this to work the /etc/printcap entry must include an # accounting file (af=...): @@ -32,46 +31,54 @@ # :lp=/dev/null: # # The /usr/var/spool/lpd/PRINTNAME/.config file should contain: -# server=PC_SERVER -# service=PR_SHARENAME +# share=PC_SERVER +# user="user" # password="password" # -# E.g. -# server=PAULS_PC -# service=CJET_371 +# Please, do not modify the order in the file. +# Example: +# share=\\server\deskjet +# user="fred" # password="" # -# 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=\${$#} +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 +# share +# hostip +# user # password + eval `cat $config_file` -# -# Some debugging help, change the >> to > if you want to same space. -# -echo "server $server, service $service" >> $logfile +share=`echo $share | sed "s/[\]/\//g"` -( -# 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/bin/smbclient "\\\\$server\\$service" $password -U $server -N -P >> $logfile +if [ "$user" != "" ]; then + usercmd="-U" +else + usercmd="" +fi + +if [ "$workgroup" != "" ]; then + workgroupcmd="-W" +else + workgroupcmd="" +fi + +if [ "$translate" = "yes" ]; then + command="translate ; print -" +else + command="print -" +fi +#echo $share $password $translate $x_command > /tmp/smbprint.log + +cat | /usr/bin/smbclient "$share" "$password" -E ${hostip:+-I} \ + $hostip -N -P $usercmd "$user" $workgroupcmd "$workgroup" \ + -c "$command" 2>/dev/null