whats wrong here?!
________________
#!/bin/sh
# FILE: clean_dirs
# GOAL : To clean up directories used in Oracle processing
# LANGUAGE : shell script (sh)
# PARAMETERS : Input_File
# 11/07/02 acri - modified to cd into the directory so it will follow links
# 02/05/07 acri - modified move directories when mask is specified (var 3)
# 10/01/10 brr - modified to add host name to output file.
# 01/17/12 acri - use setup.sh include mod, validate input file is in
# /winixdb/dba/ENV/scripts/infiles
# Insure 1 command line variables
if [ $# != 1 ]; then
echo "Usage: clean_dirs Input_File"
exit 1
fi
#variables
LOG_DIR='/home/devlogic/logs'
SCRIPT_DIR='/home/devlogic/scripts'
# Set up input variables.
INFILE=$1
# Set time stamp
TIMESTAMP=`date +%y%m%d%H%M`
DATE=`date +%y%m%d`
TIME=`date +%H%M`
#set ORACLE_SID so setup.sh does not err out
# it's not used in this shell
#ORACLE_SID=XX
# call common setup.sh
#. /winixdb/dba/prod/scripts/setup.sh
# Name of program
PROGRAM=`basename $0`
# Output file for cleaning out directories.
OUTPUTFILE=${LOG_DIR}/${PROGRAM}.${HOST}.${DATE}.${TIME}
# validate input file
if [ -f ${SCRIPT_DIR}/infiles/${INFILE} ]; then
INPUTFILE=${SCRIPT_DIR}/infiles/${INFILE}
else
echo "${SCRIPT_DIR}/scripts/infiles/${INFILE} not found"
exit 4
# For each directory and age specification found in the input file run the commands shown.
for VALUE in `cat ${INPUTFILE}`
do
echo "VALUE = ${VALUE}"
DIRECTORY=`echo ${VALUE} | cut -f1 -d,`
AGE=`echo ${VALUE} | cut -f2 -d,`
#prepopulate MASK with none, if it changes, then there is a mask
MASK=`echo ${VALUE} | cut -f3 -d,`
echo "DIRECTORY = ${DIRECTORY}"
echo "AGE = ${AGE}"
echo "MASK = ${MASK}"
# check to make sure directory or link exists prior to attempting to process it
if [ -d ${DIRECTORY} ] || [ -h ${DIRECTORY} ]; then
cd ${DIRECTORY}
# List files that will be moved and pipe to the OUTPUTFILE then move the files.
# Echo a message to the screen explaining what is going on.
if [ ${MASK:=none} = 'none' ]; then
echo "${PROGRAM} is removing files ${AGE} days old from ${DIRECTORY}" >>${OUTPUTFILE}
/bin/find . -mtime +${AGE} -ls >>${OUTPUTFILE}
/bin/find . -mtime +${AGE} -exec /bin/rm -f '{}' \;
else
echo "${PROGRAM} is removing files and directories with mask ${MASK}* ${AGE} days old from ${DIRECTORY}" >>${OUTPUTFILE}
/bin/find ./${MASK}* -mtime +${AGE} -ls >>${OUTPUTFILE}
/bin/find ./${MASK}* -mtime +${AGE} -exec /bin/rm -rf '{}' \;
fi
# Check the status of the return code and echo to the output file.
rcout=$?
echo "Return code = ${rcout}" >>${OUTPUTFILE}
else
echo "========================================================" >>${OUTPUTFILE}
echo "============> ${DIRECTORY} does not exist" >>${OUTPUTFILE}
echo "========================================================" >>${OUTPUTFILE}
echo "============> ${DIRECTORY} does not exist"
fi
done