Thursday, April 17, 2008

ftp get files from remote dir

get all remote files trough ftp connection,ascii in this case,just change the asc to bin for binary transfer

#!/bin/bash
#ftp safar
host='xxxxxxxx'
user='xxx'
pass='xxx'
remoteDIR="$1"

echo $remoteDIR
remotedir=$remoteDIR
rm -rf file.txt dir.txt

function getlist
{
ftp -nv $host << a="`echo" a = "d">> ./dir.txt
else
echo "file $d"
echo $d | awk '{print $9}' >> ./file.txt
fi
done < ./remote.txt
}

function getfile
{
while read f
do
ftp -nv $host << X
user $user $pass
lcd tesftp
cd $remoteDIR
asc
get $f
bye
X
done < file.txt
}


getlist
checkfile
getfile

exit 0

0 Comment :