[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: printcap entry to use smbclient with lprng



On Mon, Mar 15, 1999 at 10:35:01AM +0100, Nils Rennebarth wrote:
[...]
> Could you send me a sample lprng printcap entry that accesses a
> Windows network printer via smbclient and also uses magicfilter.
[...]

I use modyfied file /usr/doc/samba-doc/examples/examples/printing/smbprint.
(diff attached).

My printcap entry is:

+ pc9|HP Laserjet 4L - pc9:\
+         :lp=/dev/null:\
+         :sd=/var/spool/lpd/pc9:\
+         :sh:pw#72:pl#66:px#1440:mx#0:\
+         :if=/usr/local/bin/smbprint:\
+         :af=/var/log/lp-acct:lf=/var/log/lp-errs:

My /var/spool/lpd/pc9/.config file is like:

+ server="PC9"
+ service=HP
+ password="xxxxxx"
+ smboptions="-I yy.yy.yy.yy"
+ if_filter=/etc/magicfilter/ljet4-filter


Mirek
--- smbprint:samba-doc_1.9.18p10-7.ORG	Fri Mar 12 12:02:31 1999
+++ smbprint:new	Mon Mar 15 17:49:06 1999
@@ -1,4 +1,4 @@
-#!/bin/sh -x
+#!/bin/sh -e
 
 # 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 
@@ -41,6 +41,23 @@
 #   service=CJET_371
 #   password=""
 
+function get_option ()
+{
+  local P="$1"
+  local L=${#P}
+  local p
+  shift
+
+  while [ $# -gt 0 ] ; do
+    p="$1"
+    if [ "$P" = "${p:0:L}" ] ;then
+      echo "${p:L}"
+      break
+    fi
+    shift
+  done
+}
+
 #
 # Debugging log file, change to /dev/null if you like.
 #
@@ -54,13 +71,19 @@
 #   Concat this with /.config to get the config file.
 #
 eval acct_file=\${$#}
-spool_dir=`dirname $acct_file` 
+# I get spool_dir from '-d' option passed to filter by lprng
+# I don't know about plain lpd compatybility
+spool_dir=`get_option -d "$@"` 
 config_file=$spool_dir/.config
 
 # Should read the following variables set in the config file:
 #   server
 #   service
 #   password
+# Variables below are optional:
+#   smboptions
+#   if_filter
+#   translate
 eval `cat $config_file`
 
 #
@@ -69,9 +92,13 @@
 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
+        if [ -z "$translate" ] ; then
+          echo translate
+        fi
 	echo "print -"
-	cat
-) | /usr/local/samba/bin/smbclient "\\\\$server\\$service" $password -U $server -N -P >> $logfile
+        if [ -z "$if_filter" ] ; then
+  	  cat
+	else
+	  $if_filter "$@"
+	fi
+) | smbclient "\\\\$server\\$service" "$password"  -N -P $smboptions >> $logfile

Reply to: