Return all sub directories on ftp server

Hey guys,

I'm new to the programming world in general, and I only write in applescript so far. I am trying to find a shell script that will return a list of all the sub directories (or folders) within a directory on my ftp server. The server needs a username and password. I would assume the translation to applescript would be something like below:

set ftp_path to "/path/to/dir/"
set ftp_name to "username"
set ftp_pw to "XXXXX"
set ftp_server to "ftp.mywebsite.com"
tell application "Finder"
    do shell script "missing shell command"
end tell

Is this wrong?

if I'm not mistaken, 'do shell script' doesn't allow for line breaks. You could put the script below into a file and call

do shell script "thescript"
USER=username
PASSWD=xxxxxx
HOST=ftp.mywebsite.com
ftp $HOST <<EOF
user $USER
$PASSWD
ls
quit
EOF
exit 0

You're correct. But when I ran the following script, I got the following return:

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?

USER=username
PASSWD=xxxxxx
HOST=ftp.mywebsite.com
ftp -n $HOST <<EOF
user $USER $PASSWD
ls
quit
EOF
exit 0

Thanks that worked. Is there any way to check a sub directory's list such as:

ftp.mywebsite.com-->sub A-->sub 1, sub 2, sub 3

---------- Post updated at 07:30 PM ---------- Previous update was at 07:26 PM ----------

Also, I got a return, but I got a lot of unneeded info. I only need the names of the directories. Is there any way to filter them out?

Names in Black:

"Illegal EPRT command

drwxr-xr-x 2 root root 4096 May 30 2008 bin
drwxr-x--- 2 root psaserv 4096 Jul 23 16:06 conf
drwxr-xr-x 2 root psaserv 4096 May 30 2008 error_docs
drwxr-xr-x 2 root root 4096 May 30 2008 etc
drwxr-xr-x 2 root root 4096 May 30 2008 lib
drwxr-x--- 2 root psaserv 4096 Jun 6 2008 pd
drwx------ 2 comcastcs root 4096 May 30 2008 private
dr-xr-x--- 7 root psaserv 4096 May 30 2008 statistics