home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume7
/
lp-remote
/
remotelp
/
remote
< prev
Wrap
Text File
|
1989-07-08
|
3KB
|
144 lines
# NAME /usr/spool/lp/model/remote
# DATE Thu Jul 14 13:31:26 BST 1988
# AUTHOR Paul Blackburn, DRSBC, ICL, Bracknell
# PURPOSE This is a 'remote' spooler script for any printer.
# This works by sending a 'uux' print request to a neighboring
# machine (NEXT).
#
# This is a 'data-driven' script...
# /usr/spool/lp/db is used to get data for a particular printer.
#
# (local) Options:
#
# -os = small print (portrait)
# -ol = small print (landscape)
LOG=/usr/spool/lp/log
DB=/usr/spool/lp/db
MODEL=`basename $0`
TEMP=/usr/tmp/${MODEL}.$$
if [ ! -f ${DB} ]
then
echo "${MODEL}: unable to open ${DB}" >>$LOG
echo "${MODEL}: aborted" >>$LOG
exit 1
fi
grep "^${MODEL}:" ${DB} >${TEMP}
DATA=`cat ${TEMP}`
if [ -z "${DATA}" ]
then
echo "${MODEL}: unable to get data from ${DB}" >>$LOG
echo "${MODEL}: aborted" >>$LOG
rm -f ${TEMP}
exit 1
fi
NEXT=`cut -f2 -d":" <${TEMP}`
DESC=`cut -f3 -d":" <${TEMP}`
RMODEL=`cut -f4 -d":" <${TEMP}`
if [ -z "${RMODEL}" ]
then
RMODEL=${MODEL}
fi
SMALL=`cut -f5 -d":" <${TEMP}`
LAND=`cut -f6 -d":" <${TEMP}`
rm -f ${TEMP}
echo "${MODEL}: DESC=${DESC}, NEXT=${NEXT}" >>$LOG
if [ -z "${NEXT}" ]
then
echo "${MODEL}: unable to determine next machine" >>$LOG
echo "${MODEL}: aborted" >>$LOG
exit 1
fi
TITLE=
OPTIONS=
COPIES=
if [ -n "$3" ]
then
TITLE="-t\"$3\""
else
user=`grep "^$2:" /etc/passwd | line | cut -d: -f5`
if [ -z "$user" ]
then
user=$2
fi
TITLE="-t\"${user}\""
fi
if [ -n "$4" ]
then
COPIES=-n$4
fi
param5=$5
shift;shift;shift;shift;shift
files="$*"
# Split out local options from options for remote lp...
LOCALOPT=""
for i in ${param5}
do
echo "${MODEL}: option=${i}" >>${LOG}
case "${i}" in
s|l ) # local options
LOCALOPT="${LOCALOPT} ${i}"
;;
* ) # other options simply passed to remote lp
OPTIONS="${OPTIONS} -o${i}"
;;
esac
done
OPTIONS="${OPTIONS} -oh"
if [ -z "${LOCALOPT}" ]
then
cat ${files}|uux - -n ${NEXT}!lp ${COPIES} ${OPTIONS} -d${RMODEL}
else
LOCALOPT=`echo ${LOCALOPT}`
for i in "${LOCALOPT}"
do
echo "${MODEL}: local option=${i}" >>${LOG}
case "${i}" in
s ) # small print (portrait)
if [ -z "${SMALL}" ]
then
echo "${MODEL}: no small cmd\c" >>${LOG}
echo " found in ${DB}" >>${LOG}
else
# echo "${MODEL}: small cmd:" >>${LOG}
# echo "${SMALL}" | od -cx >>$LOG
echo "${SMALL}"
fi
;;
l ) # small print (landscape)
if [ -z "${LAND}" ]
then
echo "${MODEL}: no land cmd\c" >>${LOG}
echo " found in ${DB}" >>${LOG}
else
# echo "${MODEL}: land cmd:" >>${LOG}
# echo "${LAND}" | od -cx >>$LOG
echo "${LAND}"
fi
;;
* ) # unknown!
echo "${MODEL}: unknown local option" >>${LOG}
;;
esac
done|cat - ${files}|uux - -n ${NEXT}!lp ${COPIES} ${OPTIONS} -d${RMODEL}
fi
echo "${MODEL}: COPIES=${COPIES}, OPTIONS=${OPTIONS}, TITLE=${TITLE}" >> ${LOG}
echo "${MODEL}: warning - ignoring title" >> ${LOG}
echo "${MODEL}: completed on `date` for ${NEXT}" >> ${LOG}
exit 0