loop logic inside of an inline redirect?

i need to log the feedback from the ftp server as i'm performing some deletes.
the only way i know of to do this is with the inline redirect << EOF
... but from there to the closing EOF, it's like i'm at the ftp command prompt, so I don't know how to have ksh script logic in there
I have an array of file names to delete and am looping them.... which requires reconnecting for every file. :frowning:

Is there a way to loop the file list and issue a delete for each, while logging the feedback... without re-connecting for each file?
connect once, delete many, & capture it all.

here is the function in the korn shell script...

function removeFiles {
for aFile in ${MFfilesToDelete
[*]}
do
ftp -ivtn ${MF_IP} >> "${FTPLOG}.$1" >&1 <<EOF
user ${MF_USER} ${MF_PASS}
rm ${aFile}
bye
EOF
done
}

-----Post Update-----

Those redirects are called 'here documents' in unix. Put the filename array into a flat file

echo "
user ${MF_USER} ${MF_PASS}
$(awk '{print "rm", $0" }' filenames_file)
bye
" | /usr/bin/ftp -ivt ${MF_IP} > "${FTPLOG}.$1" 

something like this:

#!/bin/ksh

function removeFiles {
ftp -ivtn ${MF_IP} >> "${FTPLOG}.$1" >&1 <<EOF
user ${MF_USER} ${MF_PASS}
$(
for aFile in ${MFfilesToDelete[*]}
do
   echo "rm ${aFile}"
done
)
bye
EOF
}

so we can use $() within a here document to execute something

Sweet!
Thank you both. that's working