: # @(#) Visionfs Printer File 1.0 06-01-2000 # # Copyright (C) 2000 Clinton A. Pownall # All rights reserved. # # The information in this file is provided for the exclusive use of # the licensees of The Santa Cruz Operation, Inc. Such users have the # right to use, modify, and incorporate this code into other products # for purposes authorized by the license agreement provided they include # this notice and the associated copyright notice with any such product. # The information in this file is provided "AS IS" without warranty. # # VisionFS Printers # # Options: lp -ob no banner # # # USAGE: # Copy this file (visionfs) into the /usr/spool/lp/model directory # Run mkdev lp # # Printer ---> Add Local # Name: The name of the printer # Description: Printer Description # Model: visionfs # mkdev lp will overlay this file in /usr/spool/.../interfaces directory # Device: /dev/null # # vi the printer's_name file in the interfaces directory # /usr/spool/lp/admins/lp/interfaces # Change the line PRINTERPATH under Global Variables Section below # to read PRINTERPATH=//PC_IP_OR_NAME/PRINTER_SHARE_NAME # Where PC_IP is the IP Address of the PC # Or use the PC name in /etc/hosts # PRINTER_SHARE_NAME is the name of the shared printer on the PC # # For example if the PC is called pc1 and the printer shared on # pc1 is called HP1100A then the PRINTERPATH variable unde the # Global Variables would look like: # PRINTERPATH=//pc1/HP1100A # #Global Variables # printerpath = //pc_ip_or_name/printer_share_name ** Change for each printer ** PRINTERPATH=//PC_IP_OR_NAME/PRINTER_SHARE_NAME FORMFEED=\\014 TMPFILE=/tmp/vfspr.`date +%M%S` TMPFILE1=/tmp/vfspr1.`date +%M%S` VISIONFS="/usr/vision/bin/visionfs" ########### ## Check arguments ########### parse () { echo "`expr \"$1\" : \"^[^=]*=\(.*\)\"`" } #Set up the default filter. if [ -x "${LOCALPATH}/lp.cat" ] then LPCAT="${LOCALPATH}/lp.cat 0" else LPCAT="cat" fi #If we are not using a filter, use the default one. if [ -z "${FILTER}" ] then FILTER="${LPCAT}" fi if [ -x "${LOCALPATH}/drain.output" ] then DRAIN="${LOCALPATH}/drain.output 1" else DRAIN= fi printer=`basename $0` request=$1 name=$2 title=$3 copies=$4 options=$5 shift; shift; shift; shift; shift # border around the banner x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" banner=no raw=yes # Strings to send to printer before file inistr="" # Strings to send to printer after file endstr="\f" if [ -z "${BANNERS}" ] then nhead=1 else nhead=${BANNERS} fi for i in $options; do case $i in b|nobanner) banner=no ;; r|raw) raw=yes ;; esac done [ "$banner" = yes ] && { # get the local system id if test -r /etc/systemid; then sysid=`sed 1q /etc/systemid` else sysid=`uname -n` fi # user = fifth field of /etc/passwd user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd` # nhead gets the value of BANNERS or 1 by default # nhead=`sed -n 's/^BANNERS=//p' /etc/default/lpd` # [ "$nhead" -ge 0 -a "$nhead" -le 5 ] || nhead=1 # print the banner $nhead times while [ "$nhead" -gt 0 ] do echo "$x\n" banner "$name" echo "$x\n" [ "$user" ] && echo "User: $user\n" echo "Request id: $request\n" echo "Printer: $printer\n" date echo "\nMachine: $sysid\n" [ "$title" ] && banner $title echo "\f\c" nhead=`expr $nhead - 1` done } # send the file(s) to the standard out $copies times while [ "$copies" -gt 0 ] do for file do if [ "${raw}" = "yes" ] then cat $file | xtod > $TMPFILE # strip the ^Z character created with xtod sed s///g $TMPFILE > $TMPFILE1 echo "$FORMFEED\c" >> $TMPFILE1 $VISIONFS print $PRINTERPATH $TMPFILE1 rm $TMPFILE rm $TMPFILE1 else awk -v INISTR="${inistr}" \ -v ENDSTR="${endstr}" \ -e 'BEGIN { if ( length(INISTR) > 0 ) { printf("%s",INISTR); }} { printf("%s\r\n",$0); } END { if ( length(ENDSTR) > 0 ) { printf("%s",ENDSTR); }}' < $file | \ $VISIONFS print $PRINTERPATH - fi done copies=`expr $copies - 1` done exit 0