I would use curl :
Code:
#!/bin/bash
temp=~/myftp.temp
url=$1
curl $1 > $temp
# if you need a ftp passive connection, do that instead :
# curl --ftp-pasv $1 > $temp
if [ ! $? -eq 0 ]; then
echo "URL $url is not valid"
exit 1
fi
# from that point the list of files and directory is in the file ~/myftp.temp
cat $temp
# if you want it on a variable
list=$(cat $temp)
# delete the file for cleanning
rm $temp
save it to, say 'myftp', then chmod +x it and execute it with the url as argument :
./myftp
ftp://arandomsite