return to PRS Technologies website
################################################################################
#
# Module: fix_winoutstat2.sh
#
# Description:
# put Unix files not referenced by Elite winoutstat into a RECYCLE bin
# for all users
#
# Author: Peter R. Schmidt
#
# Change Log
#
# Date Person Description
#
# 03/28/2002 Peter Schmidt Start program
#
################################################################################
echo "Searching $REPORTDIR"
rm -f unix_files1.unl
rm -f missing_in_elite.unl
rm -f delete_rpt2.out
find $REPORTDIR -name "TEMP.*" -mtime +7 -print > unix_files1.unl
dbaccess son_db <<-EOF
!echo "create temp table: peter1 (contains list of files in unix)."
create temp table peter1 ( f1 char(100) );
!echo "create temp table: peter2 (contains list of files in elite)."
create temp table peter2 ( f1 char(100) );
!echo "Loading list of unix files into Informix table: peter1..."
load from "unix_files1.unl" insert into peter1;
create index peter1_1 on peter1 (f1);
!echo "Loading list of elite files into Informix table: peter2..."
insert into peter2 select wofile from winoutstat where wofile is not null;
create index peter2_1 on peter2 (f1);
!echo "Unload to missing_in_elite where file is in unix, but not in elite."
unload to "missing_in_elite.unl"
select f1 from peter1
where f1 not in (select f1 from peter2);
EOF
rm -f unix_files1.unl
echo
echo "Press to report on missing files found ( to quit )"
read answer
echo
echo "Reporting on files..."
echo
for FILENAME in `cat missing_in_elite.unl | cut -d"|" -f1`
do
ls -l $FILENAME >> delete_rpt2.out
done
pg delete_rpt2.out
echo
echo "Press to delete unix files not referenced in elite ( to quit)"
read answer
if [ ! -d RECYCLE_BIN2 ]; then
mkdir RECYCLE_BIN2
fi
for FILENAME in `cat missing_in_elite.unl | cut -d"|" -f1`
do
echo "mv $FILENAME RECYCLE_BIN2"
mv $FILENAME RECYCLE_BIN2
done
echo
echo "Completed"
################################################################################