【问题标题】:Removing a file from ftp with cUrl使用 cUrl 从 ftp 中删除文件
【发布时间】:2018-03-02 00:40:18
【问题描述】:

我正在尝试在命令行中从我的 ftp 服务器中删除一个文件。它看起来像这样:

curl -v -O ftp://192.168.26.10/inbox/project/logs/video/super_user_2017-09-25_19-20-27.webm -Q 'DELE inbox/project/logs/video/super_user_2017-09-25_19-20-27.webm'

文件已删除,但输出看起来很奇怪,据我所知 curl 返回错误。所以输出:

< 220 NASFTPD Turbo station 1.3.5a Server (ProFTPD)
> USER anonymous
< 331 Anonymous login ok, send your complete email address as your password
> PASS ftp@example.com
< 230 Anonymous access granted, restrictions apply
> PWD
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0< 257 "/" is the current directory
* Entry path is '/'
> DELE inbox/project/logs/video/super_user_2017-09-25_19-20-27.webm
* ftp_perform ends with SECONDARY: 0
< 250 DELE command successful
> CWD inbox
< 250 CWD command successful
> CWD project
< 250 CWD command successful
> CWD logs
< 250 CWD command successful
> CWD video
< 250 CWD command successful
> EPSV
* Connect data stream passively
< 229 Entering Extended Passive Mode (|||55808|)
* Hostname was NOT found in DNS cache
*   Trying 192.168.26.10...
* Connecting to 192.168.26.10 (192.168.26.10) port 55808
* Connected to 192.168.26.10 (192.168.26.10) port 21 (#0)
> TYPE I
< 200 Type set to I
> SIZE super_user_2017-09-25_19-20-27.webm
< 550 super_user_2017-09-25_19-20-27.webm: No such file or directory
> RETR super_user_2017-09-25_19-20-27.webm
< 550 super_user_2017-09-25_19-20-27.webm: No such file or directory
* RETR response: 550
* Remembering we are in dir "inbox/project/logs/video/"
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host 192.168.26.10 left intact
curl: (78) RETR response: 550

我的命令有什么问题?非常感谢!

【问题讨论】:

    标签: curl ftp


    【解决方案1】:

    我了解问题所在,因此我将尝试回答我自己的问题。我稍微改变了命令。所以现在看起来是这样的

    curl -v  ftp://192.168.26.10/inbox/project/logs/video  -Q"DELE /inbox/project/logs/video/super_user_2017-09-25_19-20-27.webm"
    

    /inbox/project/logs/video/super_user_2017-09-25_19-20-27.webm

    是您尝试删除的文件的完整路径。

    ftp://192.168.26.10/inbox/project/logs/video/

    是包含文件的目录。删除文件后 curl 在远程服务器上运行 LIST 命令以显示文件已成功删除。这就像在午夜指挥官中删除文件一样。您删除该文件,它会自动为您刷新目录。我的错误是我使用的不是目录而是文件本身

    ftp://192.168.26.10/inbox/project/logs/video/super_user_2017-09-25_19-20-27.webm

    所以在删除 curl 后检查文件是否被成功删除并在 ftp 服务器上运行 RETR。并在尝试检索此文件时出错,因为它尚不存在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      相关资源
      最近更新 更多