-1

I have prepared a shell script which takes 6 char(s) from a file and insert a particular record using sql insert query within a while loop(as the number of records in file is huge).

Upon running the script I am receiving below error - ./TestScriptFor.sh: line 40: syntax error: unexpected end of file

#!/bin/bash

varSIAREQUESTID=$1
varCINAME=$2
#varWORDLENGTH=$3
#DB connection parameter


DBUSER='#USERNAME#'
DBUSERPASSWORD='#PWD#'
DB='oracle'
MYDB='#CONNECTIONSTRING#'

OLDIFS=$IFS

# while loop
while IFS= read -r -n6 LOCATIONID
do
    #insert into database 
    sqlplus -s ${DBUSER}/${DBUSERPASSWORD}@${MYDB} <<EOT
    set linesize 32767
    set feedback off
    set heading off
    insert into nbn_sia_locationids (siarequestid,locationid,ciname) values('$varSIAREQUESTID','$LOCATIONID','$CINAME');
    exit
EOT
        echo  "$LOCATIONID"


    # display one character at a time

done < TestData.csv
IFS=$OLDIFS

1 Answers1

0

Thanks for your responses.

I did below two steps to resolved the issue - 1. dos2unix TestData.csv - although I had created this file in UNIX itself but did this as well. 2. a new line at the end of the file as suggested by @cdark

regards, dhananjay