【发布时间】:2017-08-21 21:57:56
【问题描述】:
我正在尝试使用 LFTP 来镜像在 Windows 上运行的远程 FTP(这就是我所知道的关于它的配置。另外,我只有读取权限)
我正在运行以下 shell 脚本:
#!/bin/bash
HOST='omitted'
USER='omitted'
PASS='omitted'
LOCALFOLDER="omitted"
REMOTEFOLDER="/Initial data/Practice area/Intellectual Property/"
lftp -f "
debug -o debug.text 9
open $HOST
user $USER $PASS
cd '$REMOTEFOLDER'
ls
mirror --reverse --verbose '$REMOTEFOLDER' '$LOCALFOLDER'
bye
"
运行后得到如下输出:
source: Is a directory
drwxr-xr-x 1 ftp ftp 0 Mar 23 2017 03.17.17
drwxr-xr-x 1 ftp ftp 0 Nov 05 2016 2016.10.03
drwxr-xr-x 1 ftp ftp 0 Nov 05 2016 2016.10.07
drwxr-xr-x 1 ftp ftp 0 Feb 23 2017 2017.02.21
drwxr-xr-x 1 ftp ftp 0 Feb 26 2017 2017.02.24
drwxr-xr-x 1 ftp ftp 0 Mar 02 2017 2017.02.27
drwxr-xr-x 1 ftp ftp 0 Apr 11 2017 2017.03.17
drwxr-xr-x 1 ftp ftp 0 Mar 28 2017 2017.03.27
drwxr-xr-x 1 ftp ftp 0 Apr 04 2017 2017.03.31
drwxr-xr-x 1 ftp ftp 0 Aug 09 08:34 2017.04.06
drwxr-xr-x 1 ftp ftp 0 Jun 07 2017 2017.05.31
drwxr-xr-x 1 ftp ftp 0 Jul 17 10:52 2017.07.17
drwxr-xr-x 1 ftp ftp 0 Feb 19 2017 New Folder
mirror: Access failed: /Initial data/Practice area/Intellectual Property: No such file or directory
如您所见,我可以列出要镜像的文件夹内的所有文件,但镜像命令失败。
以下是调试输出:
---- Resolving host address...
---- 1 address found: <omitted>
---- Connecting to <omitted> (<omitted>) port <omitted>
<--- 220 Welcome to <omitted>
---> FEAT
<--- 211-Features:
<--- MDTM
<--- REST STREAM
<--- SIZE
<--- MLST type*;size*;modify*;
<--- MLSD
<--- UTF8
<--- CLNT
<--- MFMT
<--- 211 End
---> CLNT lftp/4.6.3a
<--- 200 Don't care
---> OPTS UTF8 ON
<--- 530 Please log in with USER and PASS first.
---> USER <omitted>
<--- 331 Password required for <omitted>
---> PASS <omitted>
<--- 230 Logged on
---> CLNT lftp/4.6.3a
<--- 200 Don't care
---> OPTS UTF8 ON
<--- 200 UTF8 mode enabled
---> PWD
<--- 257 "/" is current directory.
---- CWD path to be sent is `/Initial data/Practice area/Intellectual Property'
---> CWD Initial data
<--- 250 CWD successful. "/Initial data" is current directory.
---> CWD Practice area
<--- 250 CWD successful. "/Initial data/Practice area" is current directory.
---> CWD Intellectual Property
<--- 250 CWD successful. "/Initial data/Practice area/Intellectual Property" is current directory.
---> PASV
<--- 227 Entering Passive Mode (<omitted>)
---- Connecting data socket to (<omitted>) port <omitted>
---- Data connection established
---> LIST
<--- 150 Connection accepted
---- Got EOF on data connection
---- Closing data socket
<--- 226 Transfer OK
**** /Initial data/Practice area/Intellectual Property: No such file or directory
---> QUIT
<--- 221 Goodbye
---- Closing control socket
如果您知道出了什么问题,我真的很感激 :)
谢谢,
【问题讨论】:
-
上传时,mirror的第一个参数应该是本地目录。
-
根据LFTP manual 的顺序是 mirror [OPTS] [source [target]] 。如果我切换这些参数,我会被拒绝,这是有道理的,因为我没有写入权限来将任何内容保存到 FTP。
-
那就不要使用 --reverse 上传到服务器了。