APPENDIX Y:

Script "chk_prtr"

SCRIPT chk_prtr:

This script will type for you all the Unix commands required to gather all printer-related parameters from the hard drive of any 51 station. (An AP20 version is coming...).

Instead of using several commands (grep, more, bpatch) to gather the printer configuration parameters, the script will do it for you in a few seconds.

Initially you should run it on the station hosting either the printer itself or the COMM Processor where the printer is attached.

If you have trouble printing from stations different from the printer host, run the script also on those stations.

Each station configures a printer according to its point of view. The printer might be a local host in one station and a remote one on others. The commands to configure the same printer will vary depending on those conditions.

Fixing the printer configuration on one station doesn't mean the other stations should be able to print on that printer.

To install it: Create directory /opt/ac/ at the printer host and copy the script into that directory. Type then: chk_prtr , and the report will be produced as an ascii file "Printers" in the same directory.



#!/bin/sh
#
# chk_prtr
#
# By: A.Corbera
#
# Purpose: Get Printer's Port and Software types from files on this station:
#  1. /etc/printers (Port Types)
#  2. /usr/fox/sp/IIF.prm (Software Types) from System Cfg
#  3. /usr/fox/sp/files/PMlbug.CS (Comm files)
#  for debugging purposes.
#
cd /opt/ac
echo "Getting data from /etc/printers ..."
echo "\nReport generated on `uname -n` at: `date`" > Printers
echo "\n1) ======== (ALL) PRINTERS FROM  /etc/printers ============" >> Printers
echo " LP:  SoftwTyp:   Printer:" >>Printers
sort /etc/printers >>Printers

echo "Getting data from IIF.prm and IIF.dat ..."
echo "\n\n2) ==== (ALL) PRINTER-HOST INFO FROM:  /etc/printers  AND IIF.prm/IIF.
dat =====" >>Printers
#echo "Combined data from /etc/printers and IIF.prm/.dat :"
#echo "Lpxx  Host/Port  /etc/printers   PortType" >>Printers
echo "Lpxx  Host/Port     /etc/printers      IIF.prm/IIF.dat:" >>Printers
PRM="/usr/fox/sp/IIF.prm"
DAT="/usr/fox/sp/IIF.dat"
LPS=`sort /etc/printers | awk '{print $1}'`
for x in $LPS
do
 PRTR_SOFT=`grep $x /etc/printers | awk '{print $2}'`
 sta=`grep $x $PRM | egrep 'P1LN|P2LN|P3LN|P4LN' | awk '{print $2}'`
 port=`grep $x $PRM | egrep 'P1LN|P2LN|P3LN|P4LN' | awk '{print substr($4,1,2)}'
`
 IIF_PORT=`awk '{print $2,$4,$6}' $PRM| grep $sta | grep $port | grep DEV | awk
'{print $3}'`
 DAT_PORT=`awk '{print $2,$4,$6}' $DAT| grep $sta | grep $port | grep DEV | awk
'{print $3}'`
 echo "$x: $sta/$port        $PRTR_SOFT                  $IIF_PORT-$DAT_PORT" >>
 Printers
done
#

echo "Getting data from files for LOCALLY hosted COMM processors ..."
COMMS=`awk ' $2 == "101" {print $1}' /usr/fox/sp/hldb`
#COMML=`awk ' $2 == "101" {print $1}' /usr/fox/sp/hldb`
echo "\n\n3) ======== (LOCALLY HOSTED) COMM PROCESSOR  PRINTERS ==============="
 >>Printers
echo "Comm processors in the system, from /usr/fox/sp/hldb:  \c" >>Printers
echo $COMMS >> Printers
echo "Comm Processors hosted by this station ($HOST)" >> Printers
for x in $COMMS
do
   echo $x
   grep $x /usr/fox/sp/sldb | awk ' $2 == "'$HOST'" {print $1}' >> Printers
done

echo "Port TYPES for Comm Processors hosted by this station from /usr/fox/sp/fil
es/PMxxxxxx.CS:" >>Printers
ls /usr/fox/sp/files/PM*.CS |grep .CS > /dev/null
if [ $? -eq 0 ]
then
   for x in $COMMS
   do
     if [ -f /usr/fox/sp/files/PM$x.CS ]
     then
        /usr/foxbin/bpatch -d /usr/fox/sp/files/PM$x.CS > z 2>/dev/null
        P1=`grep 00: z | awk '{print $4}'`
        P2=`grep 01: z | awk '{print $8}'`
        P3=`grep 02: z | awk '{print $12}'`
        P4=`grep 03: z | awk '{print $16}'`
        echo "$x: P1=$P1\tP2=$P2\tP3=$P3\tP4=$P4" >>Printers
     fi
   done
else
   echo "This station does NOT host any COMM processors!" >> Printers
fi

echo "Getting data for LOCAL DIRECT connected printers ..."
echo "\n\n4) ========== (LOCAL) DIRECT CONNECTED  PRINTERS (cs_cfg.pars) =======
====" >>Printers
if [ -f /usr/fox/sp/files/cs_cfg.pars ]
then
  echo " LP:    Device:         Port Type:" >>Printers
  DIR="/usr/fox/sp/files/cs_cfg.pars"
  egrep 'NAME|TYPE' $DIR | sed -e 's/=/ = /'|sed -e 's/#/ # /'|awk '
    $1 == "LPNAME" {printf "%-0s\t",$3}
    $1 == "PTNAME" {printf "%-0s\t",$3}
    $1 == "LPTYPE" {printf "%-0s\n",$3}' >>Printers
fi

echo "Getting data from files for PCL3 printers ..."
echo "\n\n5) ========== FILES FOR PCL3 (HP870/890/895) PRINTERS ===========" >>P
rinters
ls -l /etc/printscreen.printers >>Printers
ls -l /etc/printscreen.options >>Printers
echo "\n /etc/printscreen.options :" >>Printers
echo "All your direct-connect PCL3 (HP870/890/895) printers should be here!" >>P
rinters
if [ -f /etc/printscreen.options ]
then
   cat /etc/printscreen.options | grep -v LPxx >>Printers
else
   echo "File does NOT exist!" >>Printers
fi
echo "\n\n6) ========== /usr/local/local_printer ==========" >>Printers
echo "This file should exist ONLY if you have a DIRECT Serial printer." >> Print
ers
if [ -f /usr/local/local_printer ]
then
   ls -l /usr/local/local_printer >>Printers
else
   echo "File 'local_printer' does NOT exist!" >>Printers
fi

echo "\n\n7) ========== PRINTER INTERFACES ==========" >>Printers
ls -l /etc/lp/interfaces >>Printers

echo "\n\n8) ========== SYSTEM PRINTERS (Remote & Local) ==========" >>Printers
echo "Printer    Type (bsd/s5)" >>Printers
lpsystem -l | awk ' /System/ {printf "%-10s ", $2}
                    /Type/   {printf "%5s\n", $2}' | grep LP >>Printers

echo "\n\n9) ========== SYSTEM PRINTERS (Remote) ==========" >>Printers
echo "System printers, except local one"
lpstat -s | grep system | egrep -v default | sort +2 >>Printers

echo "\n\n10) ========== OTHER PRINTSCREEN RELATED FILES ==========" >>Printers

echo "Note: Lexmark printer requires 'xwd2ps' to be: 57736, Jul 8, 1999\n" >>Pri
nters
ls -l /usr/fox/wp/bin/xwd2ps  >>Printers

ls -l /usr/fox/wp/bin/jettool >>Printers
ls -l /usr/fox/wp/bin/r2grab >>Printers
ls -l /usr/fox/wp/bin/foxwd >>Printers
ls -l /usr/fox/wp/bin/foxpr >>Printers
ls -l /usr/fox/exten/standard >>Printers
ls -l /usr/fox/exten/pjet_graphics >>Printers

echo "\n================ THE END =======================" >>Printers
echo "This information was saved in current directory as file: Printers" >> Prin
ters

more Printers

1