我最初将其发布在服务器故障中,但没有引起太大关注。我希望这里有人能提供帮助。
我正在尝试编写一个脚本来将一些文件从远程 ftp 服务器复制到本地目录。最终我希望能够按修改日期进行过滤,但现在我只是想获取一个简单目录副本的句柄。我见过很多使用lftp 镜像命令的例子,但到目前为止,它们似乎都不起作用。目前我有一个如下所示的命令:
lftp -u myuser ftp.myserver.net -e 'set ftp:ssl-allow no;mirror -c --verbose eyerep-test/outgoing/archive ~/eyerep-files/outgoing;quit;'
如果我执行该命令,它将连接到服务器并尝试运行镜像命令,但是当它完成时,我没有看到任何文件复制到我的计算机上的 ~/eyerep-files/outgoing 文件夹中。我还尝试使用 lftp 连接到远程并一次运行一个命令。我得到了相同的结果。我不太确定我在这里做错了什么。谁能解释一下为什么这个命令不起作用?
更新: 为了确保这不是远程服务器的问题,我决定尝试对公共 ftp 服务器运行一些命令,看看发生了什么。
我跑:
cd /home/pbuchheit/eyerep-files
lftp apache.cs.utah.edu
cd apache.org/zzz
mirror -c --transfer-all --verbose=2 --script=cmd.log
quit
以下命令已记录到 cmd.log 文件中,但当我查看目录时,我实际上没有看到任何应该复制的文件或目录。
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/HEADER
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/HEADER.html
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/HEADER.txt
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/README
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/README.html
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/README.txt
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/checkrev.py
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/find-ls.gz
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/status.json
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/time.txt
get -O /home/pbuchheit/eyerep-files ftp://apache.cs.utah.edu/apache.org/zzz/update-files.sh
mkdir file:/home/pbuchheit/eyerep-files/checker-tests
get -O /home/pbuchheit/eyerep-files/checker-tests ftp://apache.cs.utah.edu/apache.org/zzz/checker-tests/README.html
chmod 644 file:/home/pbuchheit/eyerep-files/checker-tests/README.html
mkdir file:/home/pbuchheit/eyerep-files/mirror-tests
get -O /home/pbuchheit/eyerep-files/mirror-tests ftp://apache.cs.utah.edu/apache.org/zzz/mirror-tests/1mb.img
get -O /home/pbuchheit/eyerep-files/mirror-tests ftp://apache.cs.utah.edu/apache.org/zzz/mirror-tests/1mb.img.7z
get -O /home/pbuchheit/eyerep-files/mirror-tests ftp://apache.cs.utah.edu/apache.org/zzz/mirror-tests/1mb.img.bz2
get -O /home/pbuchheit/eyerep-files/mirror-tests ftp://apache.cs.utah.edu/apache.org/zzz/mirror-tests/1mb.img.tar.gz
get -O /home/pbuchheit/eyerep-files/mirror-tests ftp://apache.cs.utah.edu/apache.org/zzz/mirror-tests/1mb.img.tgz
get -O /home/pbuchheit/eyerep-files/mirror-tests ftp://apache.cs.utah.edu/apache.org/zzz/mirror-tests/1mb.img.zip
get -O /home/pbuchheit/eyerep-files/mirror-tests ftp://apache.cs.utah.edu/apache.org/zzz/mirror-tests/Readme.txt
mkdir file:/home/pbuchheit/eyerep-files/mirror-tests/redirect-test
chmod 644 file:/home/pbuchheit/eyerep-files/mirror-tests/1mb.img
chmod 644 file:/home/pbuchheit/eyerep-files/mirror-tests/1mb.img.7z
chmod 644 file:/home/pbuchheit/eyerep-files/mirror-tests/1mb.img.bz2
chmod 644 file:/home/pbuchheit/eyerep-files/mirror-tests/1mb.img.tar.gz
chmod 644 file:/home/pbuchheit/eyerep-files/mirror-tests/1mb.img.tgz
chmod 644 file:/home/pbuchheit/eyerep-files/mirror-tests/1mb.img.zip
chmod 644 file:/home/pbuchheit/eyerep-files/mirror-tests/Readme.txt
chmod 755 file:/home/pbuchheit/eyerep-files/mirror-tests/redirect-test
mkdir file:/home/pbuchheit/eyerep-files/perms
get -O /home/pbuchheit/eyerep-files/perms ftp://apache.cs.utah.edu/apache.org/zzz/perms/file444
get -O /home/pbuchheit/eyerep-files/perms ftp://apache.cs.utah.edu/apache.org/zzz/perms/file644
get -O /home/pbuchheit/eyerep-files/perms ftp://apache.cs.utah.edu/apache.org/zzz/perms/file664
mkdir file:/home/pbuchheit/eyerep-files/perms/dir555
get -O /home/pbuchheit/eyerep-files/perms/dir555 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir555/file444
get -O /home/pbuchheit/eyerep-files/perms/dir555 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir555/file644
get -O /home/pbuchheit/eyerep-files/perms/dir555 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir555/file664
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir555/file444
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir555/file644
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir555/file664
mkdir file:/home/pbuchheit/eyerep-files/perms/dir755
get -O /home/pbuchheit/eyerep-files/perms/dir755 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir755/file444
get -O /home/pbuchheit/eyerep-files/perms/dir755 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir755/file644
get -O /home/pbuchheit/eyerep-files/perms/dir755 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir755/file664
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir755/file444
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir755/file644
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir755/file664
mkdir file:/home/pbuchheit/eyerep-files/perms/dir775
get -O /home/pbuchheit/eyerep-files/perms/dir775 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir775/file444
get -O /home/pbuchheit/eyerep-files/perms/dir775 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir775/file644
get -O /home/pbuchheit/eyerep-files/perms/dir775 ftp://apache.cs.utah.edu/apache.org/zzz/perms/dir775/file664
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir775/file444
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir775/file644
chmod 644 file:/home/pbuchheit/eyerep-files/perms/dir775/file664
mkdir file:/home/pbuchheit/eyerep-files/perms/dr-xr-xr-x
get -O /home/pbuchheit/eyerep-files/perms/dr-xr-xr-x ftp://apache.cs.utah.edu/apache.org/zzz/perms/dr-xr-xr-x/r-xr-xr-x
chmod 755 file:/home/pbuchheit/eyerep-files/perms/dr-xr-xr-x/r-xr-xr-x
chmod 644 file:/home/pbuchheit/eyerep-files/perms/file444
chmod 644 file:/home/pbuchheit/eyerep-files/perms/file644
chmod 644 file:/home/pbuchheit/eyerep-files/perms/file664
chmod 755 file:/home/pbuchheit/eyerep-files/perms/dir555
chmod 755 file:/home/pbuchheit/eyerep-files/perms/dir755
chmod 755 file:/home/pbuchheit/eyerep-files/perms/dir775
chmod 755 file:/home/pbuchheit/eyerep-files/perms/dr-xr-xr-x
mkdir file:/home/pbuchheit/eyerep-files/rsync-module
get -O /home/pbuchheit/eyerep-files/rsync-module ftp://apache.cs.utah.edu/apache.org/zzz/rsync-module/apache-dist
chmod 644 file:/home/pbuchheit/eyerep-files/rsync-module/apache-dist
chmod 644 file:/home/pbuchheit/eyerep-files/HEADER
chmod 644 file:/home/pbuchheit/eyerep-files/HEADER.html
chmod 644 file:/home/pbuchheit/eyerep-files/HEADER.txt
chmod 644 file:/home/pbuchheit/eyerep-files/README
chmod 644 file:/home/pbuchheit/eyerep-files/README.html
chmod 644 file:/home/pbuchheit/eyerep-files/README.txt
chmod 755 file:/home/pbuchheit/eyerep-files/checkrev.py
chmod 755 file:/home/pbuchheit/eyerep-files/update-files.sh
chmod 755 file:/home/pbuchheit/eyerep-files/checker-tests
chmod 755 file:/home/pbuchheit/eyerep-files/mirror-tests
chmod 755 file:/home/pbuchheit/eyerep-files/perms
chmod 755 file:/home/pbuchheit/eyerep-files/rsync-module
更新2
正如@aviro 所建议的,我尝试运行 strace 来看看幕后发生了什么。命令是:
strace -f -yy -e trace=文件 -q -o lftp.strace lftp[电子邮件受保护]
当我运行镜像命令时,我得到了输出:
429 openat(AT_FDCWD, ".", O_RDONLY|O_DIRECTORY) = 5</home/pbuchheit/eyerep-files>
429 getcwd("/home/pbuchheit/eyerep-files", 4096) = 29
429 chdir("/home/pbuchheit/eyerep-files") = 0
429 chdir("/home/pbuchheit/eyerep-files") = 0
429 chdir("/home/pbuchheit/eyerep-files") = 0
429 openat(AT_FDCWD, "/home/pbuchheit/eyerep-files", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 6</home/pbuchheit/eyerep-files>
429 lstat("/home/pbuchheit/eyerep-files/.", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
429 openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 6</etc/passwd>
429 openat(AT_FDCWD, "/etc/group", O_RDONLY|O_CLOEXEC) = 6</etc/group>
429 lstat("/home/pbuchheit/eyerep-files/..", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
429 lstat("/home/pbuchheit/eyerep-files/cmd.log", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
429 lstat("/home/pbuchheit/eyerep-files/lftp.strace", {st_mode=S_IFREG|0664, st_size=14407, ...}) = 0
429 openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_CLOEXEC) = 5</usr/share/zoneinfo/posixrules>
429 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=3545, ...}) = 0
429 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=3545, ...}) = 0
其余输出只是最后一行的几千次重复。
更新3:
我从团队中拉来了其他人来帮助测试这一点。他有一个与我相同版本的 Ubuntu 的虚拟机,当他测试 lftp 时得到了相同的结果。他还在旧版本(16.04)上进行了测试,并且它可以在那里工作。由于它适用于旧版本,我真的认为它与时区设置有关,但我仍然不确定如何修复它。