Hello Gurus!
Please help!
I would like to get some help with the following:
I'm working right now on a Data Warehouse project and I need to automate a manual procedure I am using to process the data files coming into the database, any information/ideas and or which script language to go with, would be greatly appreciated.
Procedure:
I have 2 stages directory architecture.
�Receiving_NewFiles� directory and �Files_Processed� directory:
Check the receiving directory for new files coming from an external system (ASCII format or non relational DBs format) and import/transport them into the database once this is done, rename the processed files and transfer them into an archiving directory called Files_Processed. I would also like to have this procedure run automatically every 5 minutes.
I would like to some how generate an error_log/alert_log file to monitor whether the process run successfully or not, additionally, I would also like it to record the name of any file that can't be processed or transferred.
Environment:
OS: AIX 5.2
Oracle 9i R2
Thanks a lot in advance for your help, day
So far this is what I had come with so far.
#!/usr/bin/bash
DIR='/oracle/utl_file_dir/NewFiles'
ORACLE_HOME=/
PATH=
ORACLE_SID=; export ORACLE_SID
#
# CHECK If Script is already running ?????
#
cnt=`ps -ef|grep $0|grep -v grep|grep -v $$|wc -l`
if [ ${cnt} -eq 1 ]
then
echo "Script not running " ---- continue processing
else
echo "Script running " ---- exit processing
exit
fi
#
# CHECK DATABASE AVAILABILITY
#
cnt=`sqlplus <<%|grep -i error|wc -l
username/password
exit
%`
if [ ${cnt} -eq 0 ]
then
echo "DB Available" ---- Further processing
else
echo "DB NOT AVAILABLE ....We are Down"; --- Stop
exit
fi
cd /oracle/utl_file_dir/NewFiles
for file in `ls X*`
do
echo ${file}
if [ -s ${file} ]
then
echo ${file}
cp ${file} ../../ProcessedFiles/.
echo `date` ${file} to become ${file:1} >> rename.log
mv ${file} ${file:1}
else
echo 'file not found...'
fi
done