#!/bin/ksh
# set umask to allow output files to be overwritten by other users
umask 000
export INBOUND_DIR=/home/ABC/IN
export ARCHIVE_DIR=/home/ABC/Archive
export LOG_DIR=/home/ABC/log
export SCRIPT_DIR=/proc/bin
date_str=$(date "+%Y%m%d%H%M%S")
cd $INBOUND_DIR
find . -type f -name "* *.csv" | while read f; do mv "$f" "$(echo "$f"|sed 's/ /_/g')";done
ls -ltr | grep -v ^d | awk '{print $9}' | while read f; do
VAR1=`echo $f`
$ORACLE_HOME/bin/sqlplus -s $MMUSER/$PASSWORD <<EOF
insert into ls_file_process_ind values('$VAR1','N',sysdate,sysdate);
delete ls_file_process_ind where FILE_NAME is NULL;
commit;
if [ -f ABC_*.csv ]
then
for data_file in $(ls -rt ABC_*.csv 2>/dev/null) ;
do
DATA_FILE="$INBOUND_DIR/$data_file"
BAD_FILE="$LOG_DIR/$data_file.bad"
PAR_FILE="$INBOUND_DIR/lm_con_tsf_par.par"
FILE_NAME="$data_file"
LOG_FILE="$LOG_DIR/$data_file.log"
cd $SCRIPT_DIR
#----------------------------------------------------------------------------
# Load Record information.
#----------------------------------------------------------------------------
sqlldr $UP data=$DATA_FILE control=ls_con_tsf_ctl.ctl bad=$BAD_FILE log=$LOG_FILE errors=9999 > /dev/null
retcode=`echo $?`
case "$retcode" in
0) echo "SQL*Loader execution successful" ;;
1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
2) echo "SQL*Loader execution encountered a fatal error" ;;
*) echo "unknown return code";;
esac
#----------------------------------------------------------------------------
# Move download data file to backup directory.
#----------------------------------------------------------------------------
cd $INBOUND_DIR
mv $FILE_NAME $ARCHIVE_DIR/$FILE_NAME
ls -ltr | grep -v ^d | awk '{print $9}' | while read f; do
VAR1=`echo $f`
$ORACLE_HOME/bin/sqlplus -s $MMUSER/$PASSWORD <<EOF
update ls_file_process_ind set PROCESS_IND='Y',last_update_datetime=sysdate where FILE_NAME='$VAR1';
commit;
done
else
echo "NO files found or file name is in wrong format"
fi
ERROR: 0403-057 Syntax error at line 28 : `<' is not matched.
Please help
Thanks in advance
Open in new window
Note that the "E" of "EOF" must be the first character on the line.Also, in your reporting of error codes, actually say what the "unknown" return code is
Open in new window