FTP problem !

i have a script that will perform the following steps:

1) FTP to dir a1.Then get the ls -ltr and redirect to file a1.txt
2) FTP to dir b1.Then get the ls -ltr and redirect to file b1.txt
3) FTP to dir c1.Then get the ls -ltr and redirect to file c1.txt

What i want is how shall i achieve the logic for redirecting the o/p of each directory into a separate file

script :


for i in a1 b1 c1
do
ftp -v -n ftp.retail.com <<EOF
user ask peter
prompt
cd $i
ls -ltr 
bye
EOF
done

for i in a1 b1 c1
do
VAR=$(ftp -v -n ftp.retail.com <<EOF
user ask peter
prompt
cd $i
ls -ltr
bye
EOF);echo "$VAR" > file$i.txt
done

Why don't you try this via rsh or ssh

=====code======

for i in a1 b1 c1
do

rsh -n -l user 10.10.10.18 "cd $i ; ls -lrt >$i.txt"
done