On Thu, 31 Oct 2002, Anthony Thyssen wrote:
> It is rather simple. All the lpr -h flag does is remove the
> "L" line from the control file being passed to the lpd server.
>
> As such the easy way to fix this is to add a
> :incoming_control_filter={small postscript}
>
> that either removed the line starting with "L" or
> is no line was present, add one by duplicating the "P" line
> replacing the "P" with an "L".
> ...
Thanks, that looks like a reasonable option. As usual, there are many
ways that things can be done in lprng. I might at some point go back
and investigate doing something like that. In the mean time, I've
already devised a Samba-specific solution to the problem (ie, you
still need to use "lpr -h" from UNIX, so it's not a particularly
symmetric solution). I'll go ahead and show how this was done in case
anyone else is interested. Again, we're essentially trying to
simulate "lpr -h" from PCs printing through Samba.
We have a Samba-specific printcap file with entries like this:
pr5:lp=pr5@printserver
pr5-h:lp=pr5@printserver
And, in our Samba `smb.conf' file, we've replaced these lines:
print command = /usr/local/bin/lpr -r -P%p %s
lprm command = /usr/local/bin/lprm -P%p %j
lpq command = /usr/local/bin/lpq -P%p
with these:
print command = /usr/cs/bin/samba_lpr -r -P%p %s
lprm command = /usr/cs/bin/samba_lprm -P%p %j
lpq command = /usr/cs/bin/samba_lpq -P%p
`samba_lpr' is just a wrapper for the lpr commands, and if the printer
name has a "-h" suffix, then the suffix is stripped and a "-h" option
is added to the command arguments; then the appropriate command is
exec'd with the otherwise same argument list. The samba_lpr script is
attached.
-Dan
--
Daniel E. Singer, System Administrator
Dept. of Computer Science, Duke University, Durham NC 27708 USA
#!/bin/sh
# @(#)samba_lpr 1.1 2002/10/31 16:21:17
# samba_lpr: wrapper script for Samba printing;
# see samba.conf on the Samba server;
# this is mainly to handle the "-Pprx-h" header suppression setup;
# 10/2002, D.Singer
prog=`basename "$0"`
usage="Usage: $prog [opts] file"
case "$prog" in
*lpr)
DO=print
CMD=/usr/local/bin/lpr
#CMD=./t.sh
;;
*lpq)
DO=queue
CMD=/usr/local/bin/lpq
;;
*lprm)
DO=remove
CMD=/usr/local/bin/lprm
;;
*)
echo "$prog: unknown invocation." >&2
exit 1
esac
# This script will replace these commands from the samba.conf file:
#
# print command = /usr/local/bin/lpr -r -P%p %s
# lpq command = /usr/local/bin/lpq -P%p
# lprm command = /usr/local/bin/lprm -P%p %j
#
#
# deconstruct the command line;
# find the -P option -- there *should* be one;
# fix the -P option;
# reconstruct the command line;
#
cnt=
list=
got_h=
for opt do
cnt=1$cnt
list="$list $cnt"
case "$opt" in
'-P'?*'-h')
# remove the "-h"
opt=`expr "$opt" ':' '\(.*\)-h'`
got_h=1
if [ "$DO" = print ]; then
eval "opt_$cnt=\"-h\""
cnt=1$cnt
list="$list $cnt"
fi
esac
eval "opt_$cnt=\"\$opt\""
done
#
# reconstruct; this is done with all the quoting and such to make sure
# that we don't get tripped up by space or special characters within args;
#
newcmd="\"$CMD\""
for num in $list; do
eval "opt=\"\$opt_$num\""
#echo "opt=<$opt>"
newcmd="$newcmd \"\$opt_$num\""
done
# for testing:
#echo "newcmd=<$newcmd>"
#eval "set -- $newcmd"
#echo "\$#=<$#>"
#for opt do
# echo "opt=<$opt>"
# done
#echo "exec $newcmd"
eval "exec $newcmd"
echo "$prog: should not get here!" >&2
exit 1