Linux FTP Shell
#!/bin/bash ### serverip=127.0.0.1 serveruser=username serverpass=passwd remotedir=./ localdir=~/ftp_data getftp(){ # _st=`date +%s` echo "-----------------------------------------------------------------------------------------------------" echo "[`date +"%F %T.%N"`] - start ftp download on " $serverip ftp -ivn $serverip << END_FTP open $serverip user $serveruser $serverpass binary cd $remotedir ls lcd $localdir mget test.txt close bye END_FTP echo "local directory listing" ls -l $localdir/*.txt echo -e "[`date +"%F %T.%N"`] - completed,using `expr $(date +%s) - $_st` secs." } getlftp(){ # _st=`date +%s` echo "-----------------------------------------------------------------------------------------------------" echo "[`date +"%F %T.%N"`] - start lftp download on " $serverip lftp $username:$passwd@$serverip << END_FTP set xfer:clobber on cd $remotedir ls lcd $localdir mget test.txt quit END_FTP echo "local directory listing" ls -l $localdir/*.txt echo -e "[`date +"%F %T.%N"`] - completed,using `expr $(date +%s) - $_st` secs." } wgetftp(){ _st=`date +%s` echo "-----------------------------------------------------------------------------------------------------" echo "[`date +"%F %T.%N"`] - start ftp download on " $serverip echo "remote directory listing" #curl ftp://$serverip -u $username:$passwd #curl ftp://$serverip/test.txt -u $username:$passwd -o test.txt wget -O test.txt ftp://$username:$passwd@$serverip/test.txt #wget -nH -m ftp://$username:$passwd@$serverip/ echo "local directory listing" ls -l $localdir/*.txt echo -e "[`date +"%F %T.%N"`] - completed,using `expr $(date +%s) - $_st` secs." } ### ftp_download(){ while true do _week=`date +%w` _hour=`date +%H%M` if [ $_week -gt 0 -a $_week -lt 6 -a $_hour -ge 900 -a $_hour -le 1530 ]; then # wgetftp >> ./logs/get_ftp.log.`date +%F` 2>&1 getftp >> ./logs/get_ftp.log.`date +%F` 2>&1 fi sleep 30 done } # ftp_download
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!