script syntax error: unexpected end of file

Need help. I cannot find the reason for this error:

here is the script

Sorry to be a pain, but please can you re-post the script using CODE tags (rather than QUOTE tags).
The likely area is:
ftp -v -n $ip >>/name1/name2/$vFTPName <<EOF
EOF

I think that there is a trailing space on the "ftp" line but CODE tags are more predictable.

The EOF label must start at column 1.

cat $LOGFILE | while IFS= read line
do
   DIRS=${line%/*}
   FILENAME=${line#$DIRS/}
   ftp -v -n $ip >>/name1/name2/$vFTPName <<EOF
quote user $fuser
quote pass $ftppass
lcd ${DIRS}
cd $fpath
bin
put ${FILENAME}
bye
EOF
   done 

Or

cat $LOGFILE | while IFS= read line
do
   DIRS=${line%/*}
   FILENAME=${line#$DIRS/}
   ftp -v -n $ip >>/name1/name2/$vFTPName <<-EOF
<tab>quote user $fuser
<tab>quote pass $ftppass
<tab>lcd ${DIRS}
<tab>cd $fpath
<tab>bin
<tab>put ${FILENAME}
<tab>bye
<tab>EOF
   done 

You can rewrite theloop :

while IFS= read -u3 line
do
   . . .
done 3<$LOGFILE

Jean-Pierre.

Thank you. Here is the code

 
#!/bin/bash
# ## set messages, variables 
##################################################################################
DATE=`date +%Y%m%d`
TIME=`date +%H%M%S` 
MESSAGE1="BACKUP: OK"
MESSAGE2="BACKUP: Fail"
MESSAGE3="DELETE: OK"
MESSAGE4="DELETE: Fail"
SUM=0
set -x
#################################################################################
# ## Read paramlist.txt and look for files to be trasferred 
##################################################################################
file='/name1/name2/paramlist.txt'
while read line
do
# 
key=`echo $line | awk -F\| '{ print $1 }'`
ip=`echo $line | awk -F\| '{ print $2 }'`
fuser=`echo $line | awk -F\| '{ print $3 }'`
ftppass=`echo $line | awk -F\| '{ print $4 }'`
lpath=`echo $line | awk -F\| '{ print $5 $6 $7 $8 $9 }'`
fpath=`echo $line | awk -F\| '{ print $10 $11 $12 $13 $14}'`
subject=`echo $line | awk -F\| '{ print $15 }'`
email=`echo $line | awk -F\| '{ print $16 }'` 
#
echo "step1-$key"
#################################################################################
# ## Create log for each folder (/name1/name2/) 
# ## xrf$key$(date '+%y%m%d'.%H%M%S).log - xrfba11090729.101010.log 
# ## error code > 0 mean problem of find, no files in the folder
##################################################################################
LOGFILE="xrf$key$(date '+%y%m%d').log"
mFile="$lpath*txt"
find $mFile >> $LOGFILE 
if [ $? -gt 0 ]; 
then 
file_ctr=0
else 
file_ctr=`egrep -cv '#|^$' /name1/name2/$LOGFILE` 
fi
SUM=$(echo "$SUM + $file_ctr"|bc)
echo "total files:$SUM"
#
if [ $SUM -eq 0 ]; then
mailx -s "no FTP &subject" "$email" 
else
echo "step2-ftp"
#################################################################################
# Upload to ftp; Create ftp log and trasfer log (/name1/name2/) 
# ftp$(date '+%y%m%d'.%H%M%S).log - ftp1090729.101010.log
# DIRS # Name of source directory
# FILENAME # Name of file without directory
#################################################################################
vFTPName="ftp$key$(date '+%y%m%d').log" 
cat $LOGFILE | while IFS= read line
do
DIRS=${line%/*}
FILENAME=${line#$DIRS/}
ftp -v -n $ip >>/name1/name2/$vFTPName <<EOF 
quote user $fuser
quote pass $ftppass
lcd ${DIRS}
cd $fpath
bin 
put ${FILENAME} 
bye
EOF
done 
fi
#
echo "step3-logs"
############################################## ###################################
# Check for (226 Transfer completed)
#################################################################################
ftp_ctr=`cat /name1/name2/$vFTPName | grep 226 | wc -l` 
if [ "$ftp_ctr" = "$SUM" ]; 
then
echo "No Error"
mailx -s "$subject" "$email" < "$LOGFILE"
else
echo "Error has occured"
mailx -s "FTP failure $subject" "email@name.com" < "$LOGFILE"
exit
fi 
#
SUM=0
done </impact/conv/paramlist.txt 
#
 

Lose the trailing space character on the ftp line ! It's the space character after the EOF .
In fact you have quite a lot of lines with spurious trailing spaces.
To spot them I typed

cat scriptname|sed -e "s/ \$/X/g"

i.e. look for lines ending with a space character and change the space to an "X".

sed -i "s/ \$//g" scriptname
I used the above command to remove the last blank space. Is it correct?
Though it does not remove the blank space if there is more than on space.

No, just use "vi" or your normal editor to remove the trailing space.
The "sed" I used was just a quick way of seeing spaces - not an edit to the file.

Though the "sed" you suggest would remove the trailing space from the line ending EOF and fix the problem.

sed -i "s/ \$//g" old_scriptname > new_scriptname