实际上,我正在尝试使用CURL
在C++和Visual Studio中对FTP服务器进行一些操作。我没有麻烦做一些上传或下载与命令行工具。
但删除一些文件,我有一些错误。
下面是我输入的命令:
curl -v -u username:pwd ftp://host/FileTodelete.xml -Q '-DELE FileTodelete.xml'
这就是答案:
* Adding handle: conn: 0x1ca5260
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1ca5260) send_pipe: 1, recv_pipe: 0
* About to connect() to host port 21 (
* Trying ......
* Connected to host (...) po
< 220-FileZilla Server version 0.9.49 beta
< 220 Bienvenue sur le serveur FTP de HandTrainer
> USER username
< 331 Password required for username
> PASS pwd
< 230 Logged on
> PWD
< 257 "/" is current directory.
* Entry path is '/'
> '-DELE
* ftp_perform ends with SECONDARY: 0
< 500 Syntax error, command unrecognized.
* QUOT command failed with 500
* Closing connection 0
curl: (21) QUOT command failed with 500
* Rebuilt URL to: FileTodelete.xml'/
* Adding handle: conn: 0x1ca5260
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 1 (0x1ca5260) send_pipe: 1, recv_pipe: 0
* Could not resolve host: FileTodelete.xml'
* Closing connection 1
curl: (6) Could not resolve host: FileTodelete.xml'
而且,文件在服务器上,所以我不明白。
4条答案
按热度按时间68de4m5k1#
问题解决了!
DELE
之前的破折号不应该存在:roqulrg32#
您使用
-Q
放置命令,但-DELE file
不是常见的ftp命令。试试其中一个:bksxznpy3#
我完成这项任务,首先登录到我的FTP服务器,然后键入“?“,以获取FTP服务器可识别的命令列表。我的服务器识别的命令是“删除”。
所以,-Q“delete $fileToRemove”$serverURL
我还可以通过使用-X“DELE $fileToRemove”$serverURL来让它工作。然而,我一直得到rc=19(因为我认为“-X”选项主要适用于HTTP| HTTPS?)从curl中删除,即使文件已成功删除。
不确定其他FTP服务器是否能识别不同的命令,但这对我来说是有效的。
41zrol4v4#
附加信息,从非根目录删除文件:保留在根目录下,并仅在-Q命令上删除具有路径的文件