What's wrong with this do Shell command

This script is support to return a list of directories(or folders) from my ftp server that requires a login and password. However, I get the following return instead::

set theScript to "USER=username
PASSWD=XXXXX
HOST=ftp.mywebsite.com
ftp $HOST <<EOF
user $USER
$PASSWD
ls
quit
EOF
exit 0"
do shell script theScript

obviously, I put in my info. I double checked it to make sure I didn’t misspell anything

Returned:

“Name (ftp.mywebsite.com:HOME): Login incorrect.
?Invalid command.
Please login with USER and PASS
Please login with USER and PASS
Please login with USER and PASS
Please login with USER and PASS”

Is that something that might be an issue with the applescript command or the shell?

Hi,
Try this:

set theScript to "USER='username'
PASSWD='XXXXX'
HOST='ftp.mywebsite.com'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
ls
quit
EOF
exit 0"
do shell script theScript

the trick:
Using the -n option on the ftp client program to prevent the ftp client from trying to log in immediately. That way, the ftp client does not ask for a user ID and password.
Use the ftp client program command quote to send user ID and password to the ftp server.

–Peter–

http://macscripter.net/viewtopic.php?id=30676