Linux下如何获取FTP文件名和大小? 5
Linux下如何获取FTP文件名和大小?我们是先用grep获取FTP上最新的文件夹,然后要获取这个文件夹里面所有.xml文件名和它们的大小,然后写入download.lo...
Linux下如何获取FTP文件名和大小?我们是先用grep获取FTP上最新的文件夹,然后要获取这个文件夹里面所有.xml文件名和它们的大小,然后写入download.log.接着又再扫描本地的文件名和大小与download.log比较来确认是不是下载完,下载完就删除服务器的文件夹。.sh脚本要怎么写??
mhost=scdftp01
muser=hphcws1
mpass=3dfkp12p
mremoteloc=/data/hphmns1/hphcwsa
mlocalloc=/sw/users/cwsdev/java/apache-tomcat-5.5.34/webapps/webdav/news
mworkloc=/sw/users/cwsdev/download
mtmplog=download.log
mstart=`date`
echo "Download File Start on $mstart ......"
cd $mworkloc
ftp -n $mhost << END_SCRIPT
quote USER $muser
quote PASS $mpass
cd $mremoteloc
ls -l $mtmplog
quit
END_SCRIPT
echo "-->finding the latest folder ...."
mfoldername=`cat $mworkloc/$mtmplog | grep '^d' | cut -c55- | sort -n | sed -n '$p'`
echo "-->target folder : $mfoldername"
echo "-->creating local folder : $mfoldername"
cd $mlocalloc
if [ -d $mfoldername ]
then
echo "----->folder [$mfoldername] already exists"
else
mkdir $mfoldername
echo "----->local folder [$mfoldername] created"
fi
cd $mfoldername
echo "-->downloading files ...."
ftp -n -i $mhost << END_SCRIPT_2
quote USER $muser
quote PASS $mpass
cd $mremoteloc
cd $mfoldername 展开
mhost=scdftp01
muser=hphcws1
mpass=3dfkp12p
mremoteloc=/data/hphmns1/hphcwsa
mlocalloc=/sw/users/cwsdev/java/apache-tomcat-5.5.34/webapps/webdav/news
mworkloc=/sw/users/cwsdev/download
mtmplog=download.log
mstart=`date`
echo "Download File Start on $mstart ......"
cd $mworkloc
ftp -n $mhost << END_SCRIPT
quote USER $muser
quote PASS $mpass
cd $mremoteloc
ls -l $mtmplog
quit
END_SCRIPT
echo "-->finding the latest folder ...."
mfoldername=`cat $mworkloc/$mtmplog | grep '^d' | cut -c55- | sort -n | sed -n '$p'`
echo "-->target folder : $mfoldername"
echo "-->creating local folder : $mfoldername"
cd $mlocalloc
if [ -d $mfoldername ]
then
echo "----->folder [$mfoldername] already exists"
else
mkdir $mfoldername
echo "----->local folder [$mfoldername] created"
fi
cd $mfoldername
echo "-->downloading files ...."
ftp -n -i $mhost << END_SCRIPT_2
quote USER $muser
quote PASS $mpass
cd $mremoteloc
cd $mfoldername 展开
1个回答
展开全部
path='' #这里的$1,换成你需要的路径名,或者你不换,通过shell的参数传入
for dirlist in $(find ${path} -name *.xml)
do
echo ${dirlist}
查找,删除,比较都在这做
done
for dirlist in $(find ${path} -name *.xml)
do
echo ${dirlist}
查找,删除,比较都在这做
done
追问
能写详细点吗谢谢
1. Get the name and size of all the xml files in the directory and output into
2. Get the xml files
3. Compare the name and size in are exists and equal to the files downloaded in the local directory
4. Delete the xml files and folder in the ftp if Point 3 is True
在“
mget *.xml
quit
END_SCRIPT_2”前加上。
快又稳
2024-10-28 广告
2024-10-28 广告
在Linux环境下配置基于域名的虚拟主机,需安装Apache或Nginx等Web服务器,并编辑配置文件。以Apache为例,需创建虚拟主机配置文件,指定域名、文档根目录等,然后启用该配置文件并重启Apache服务。同样,Nginx也需在相应...
点击进入详情页
本回答由快又稳提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询