【问题标题】:linux ftp lcd error No such file or directorylinux ftp lcd错误没有这样的文件或目录
【发布时间】:2012-08-16 20:37:14
【问题描述】:

我编写了一个 bash 脚本来连接 ftp 服务器并将文件从 FTP 服务器下载到我本地 linux 机器上的不同目录。

我正在使用以下方法来实现这一点。

#! /bin/sh 
FILENAME='helloworld.txt'
USSER='username'
PASSWD='password'
ftp -niv ftp.domain.com <<HEREDOC
quote USER $USSER
quote PASS $PASSWD
lcd /home/username/scripts/data
mget $FILENAME
bye
HEREDOC

我必须使用 USSER 登录,因为 USER 是关键字

另外,我能够手动运行命令而没有任何错误。

有谁知道可能是什么问题?对此的任何帮助或在哪里寻找的线索将不胜感激。

编辑

当我运行脚本时,我得到以下信息并注意到错误消息如何覆盖了它正在回显的大部分路径

# bash test.sh
test.sh: line 11: warning: here-document at line 5 delimited by end-of-file (wan')d `HEREDOC
Connected to ftp.domain.com (ipaddress).
220 Welcome to the domain FTP Server
331 Password required for username.
230 User username logged in.
: No such file or directoryts/data
local: helloworld.txt remote: helloworld.txt
227 Entering Passive Mode (216,19,206,212,226,85)
150 Data connection accepted from myipaddress:54375; transfer starting for /helloworld.txt (107828 bytes)
226 File sent ok.
107828 bytes received in 0.137 secs (789.81 Kbytes/sec)
?Invalid command
?Invalid command
221 Goodbye.

【问题讨论】:

  • /home/username/scripts/data 实际上是否存在于您运行此脚本的系统上?我刚刚复制了您的脚本(显然具有不同的文件名、用户、密码、站点等),并且运行良好....
  • @twalberg 是的。我可以连接、更改本地目录并手动下载而不会出错,但是在运行脚本文件时会出现错误。请注意,错误在路径上重叠/写入。
  • @twalberg 这可能是我的系统设置方式吗? Fedora 发布 14 (Laughlin) Linux 2.6.35.4-rscloud x86_64

标签: linux ftp


【解决方案1】:

错误消息被覆盖的原因是您的文件名包含在错误消息中,而回车符包含在您的文件名中。你需要dos2unix那个东西并停止使用DOS-ish编辑器编辑unix脚本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-12
    • 2018-08-06
    相关资源
    最近更新 更多