互联网服务器管理脚本:FTP、SFTP同步与Apache日志分析
1. 通过FTP同步到远程目录
1.1 脚本概述
ftpsyncdown 脚本用于从远程FTP服务器的指定目录下载所有文件到本地当前目录。它利用 ftp 的 mget 命令自动检索远程目录中所有文件的内容,并逐个复制到本地系统。
1.2 代码实现
#!/bin/sh
# ftpsyncdown - Given a source directory on a remote FTP server,
# downloads all the files therein into the current directory.
tempfile="/tmp/ftpsyncdown.$$"
trap "/bin/rm -f $tempfile" 0 1 15 # zap tempfile on exit
if [ $# -eq 0 ] ; then
echo "Usage: $0 user@host { remotedir }" >&2
exit 1
fi
user="$(echo $1 | cut -d@ -f1)"
server="$(echo $1 | cut -d@ -f2)"
echo "open $server" > $tempfile
echo "user $user" >> $tempfile
if [ $# -gt 1 ] ; then
echo "cd $2" >> $t
超级会员免费看
订阅专栏 解锁全文
119

被折叠的 条评论
为什么被折叠?



