Ftp multiple files one at a time

Hi,
I have a problem while ftp'ing zip files one after the other from linux source directory to a ftp host machine. here is the shell script:

#!/bin/ksh
dir=data/dir1/dir2 # this dir is linux source directory where zip files located.
rmtdir='/home/'
echo $dir
for i in /$dir/*; do
 if [ -f "$i" ]; then
file=$i
ftp -inv <<END_SCRIPT
open host
user x133 x133
ascii
put $file $rmtdir
#sleep 5 
quit
END_SCRIPT
 fi
done

When i run the above shell script, i see that filename (say 123.zip from source directory) that is ftp'd is re-named as home instead of 123.zip.

you have to run

cd $rmtdir
put $file

It's also worth noting that if "123.zip" is an actual ZIP file, it won't be an ASCII file.

I tried the following

dir=data/dir1/dir2 # this dir is linux source directory where zip files located.
rmtdir='/home/'
echo $dir
for i in /$dir/*; do
 if [ -f "$i" ]; then
file=$i
ftp -inv <<END_SCRIPT
open host
user x133 x133
binary
cd $rmtdir
put $file $rmtdir
quit
END_SCRIPT
 fi
done

and it gave the following error:

local: /ep-data/pcats/CPS_RSPD1032/970HD.zip remote: /ep-data/pcats/CPS_RSPD1032/970HD.zip
229 Entering Extended Passive Mode (|||48492|)
450 File action is not taken.
?Invalid command.
221 Service closing control connection.

Instead of a for loop, why not use mput?

dir=data/dir1/dir2 # this dir is linux source directory where zip files located.
rmtdir='/home/'
cd $dir
ftp -inv <<END_SCRIPT
open host
user x133 x133
binary
cd $rmtdir
prompt off
mput *.zip
END_SCRIPT

Sorry if there is confusion created, but i'm trying to ftp one zip file at a time in one ftp session. If there are 100 zip files in linux source directory then 100 ftp sessions should be created and one zip file per session to be ftp'd to host machine's root directory.

Many Thanks for looking

Try disabling extended passive mode:

epsv4 off

Some info about error 450:

450 FTP Reply Code - Knowledge Base-RhinoSoft

My code worked with the following alterations, thanks for looking into it.

cd $dir
ls|while read file; do
 if [ -f "$file" ]; then
ftp -inv <<END_SCRIPT
open hostname
user user password
binary
put $file
quit
END_SCRIPT
 fi
done