#!/bin/sh # # get_csa # # Usage: get_csa # # By: Angel Corbera, TSID1, Refinery Isla, Curacao, N.A. # Comments to: corbera@rocketmail.com # # Purpose: Create a Control Blocks database (PLANT.csa) from # CSA files residing on CSA host. # Database format: # CP - CMPD - BLOCK - BLOCK_TYPE # Note: ECB blocks are included. # # Some statistics (PLANT.sum) are provided at the end. # # The output file can be used for comparison against other # databases created from ICC files (using mk_icc_db), or from CPs # (using mk_cp_db), for detecting CSA mismatches. # cd /opt/ac mv PLANT.csa PLANT.csa.old > /dev/null 2>&1 touch PLANT.csa CPS=`sort /etc/cplns` echo "\nThis program takes about 3 minutes." echo "Please be patient. ... Go and get a cup of coffee ..." for x in $CPS do echo "Retrieving data from CSA files for $x ..." /usr/fox/csa/csa_save $x | awk '$2 != ""' > z awk '{a="'$x'"}{printf "%-8s %-13s %-13s %-8s\n",a,$1,$2,$3}' z >>PLANT.csa done echo " --> PLANT.csa database is ready." rm z # echo "Building Statistics ... \c" rm PLANT.sum > /dev/null 2>&1 touch PLANT.sum TOT=`wc -l PLANT.csa|awk '{print $1}'` echo "Plant statistics for: `date`" >> PLANT.sum echo "Total blocks = $TOT" >> PLANT.sum echo "==============================================" >> PLANT.sum echo "... \c" # awk '{print $1}' PLANT.csa > tmp1 for x in $CPS do NUMBER=`grep $x tmp1 | wc -l` PCT=`expr 100 \* $NUMBER / $TOT` echo "$x blocks = $NUMBER \t( $PCT %)" >> PLANT.sum done echo "==============================================" >> PLANT.sum echo "... \c" # awk '{print $4}' PLANT.csa > tmp1 sort -u tmp1 > tmp2 for x in `cat tmp2` do NUMBER=`grep $x tmp1 | wc -l` PCT=`expr 100 \* $NUMBER / $TOT` echo "$x \tblocks = $NUMBER \t( $PCT %)" >> PLANT.sum done # rm tmp1 tmp2 echo "Done. PLANT.sum (statistics) is ready!" echo "\n Press SPACE for next page. "q" to QUIT\n" more PLANT.sum PLANT.csa