Avatar of sam shah
sam shah
 asked on

shell error(UNIX)

#!/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
Shell Scripting

Avatar of undefined
Last Comment
MURUGESAN N

8/22/2022 - Mon
simon3270

Couple of things.  You are missing the "EOF" to finish off the "here" documents, so just after the two "commit;" lines, have it as
 commit;
EOF

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
*) echo "unknown return code $retcode";;

Open in new window

sam shah

ASKER
Thanks...Its working. Can you please suggest how i can check for already existing file names in the table before the insert statement so as to avoid duplicate file names in the table.
ASKER CERTIFIED SOLUTION
simon3270

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MURUGESAN N

1. Resolved
2. Query inactive for 14 days.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy