#
#用ftp命令行递归地传输一个目录中的所有文件,包括新建子目录
#
if [ $# -ne 3 ] && [ $# -ne 5 ] then
echo "Usage : $0 host username passwd [src_path obj_path]"
exit 100
fi
host=$1
username=$2
passwd=$3
if [ $# -eq 3 ] then
src_path=`pwd`
obj_path=`pwd`
else
src_path=$4
obj_path=$5
fi
ls -l $src_path|grep "^d"|awk '{print $NF}' > path.list
echo "user $username $passwd \ncd $obj_path\nlcd $src_path\nmput *\nls \nby"|ftp -n -i $host > tmp.list
cnt=`cat path.list|wc -l`
if [ $cnt = "0" ] then
exit 0
fi
cat path.list|while read pathname
do
cnt=`cat tmp.list|grep "^d"|grep $pathname|wc -l`
if [ $cnt = "0" ] then
echo "user $username $passwd \ncd $obj_path \nmkdir $pathname\nby"|ftp -n -i $host
fi
src_path_sub=$src_path"/"$pathname
obj_path_sub=$obj_path"/"$pathname
sh $0 $host $username $passwd $src_path_sub $obj_path_sub
done
|
|
|