I want to use my script to get any file then delete it once it transfers to my side , I manage to create below script to generate "list" file which contains all file names in "10.10.1.1" then I made "a.out" file which contains the commands that I want to run it on "10.10.1.1" to get & delete the files , I feel my script still miss some statement as I tried to pass "a.out" to ftp command but went wrong , what I should do to automate my script in order to get the files & delete them as well ?
#!/usr/bin/ksh
ftp -in 10.10.1.1 << EOF
user ftpuser ftppass
cd /user/path
bin
dir *.dat ./list
bye
EOF
awk '{print $NF}' ./list | while read file; do
echo "ftp -in 10.10.1.1
user ftpuser ftppass
bin
cd /user/path
get $file
del $file
bye" >> a.out
done