probably your FTP function is not getting what it's supposed to:
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
This is an example of working one from here
Just for an option, if you could use LFTP
instead of Ftp, that would solve you much trouble with FTP scripting.