CURL command line tool - Delete File from FTP server

眉间皱痕 提交于 2019-12-01 16:38:23
Arthur Clerc-Gherardi

Problem solved !

It seems that the single quote didn't work so :

    curl -v -u username:pwd ftp://host/FileTodelete.xml -Q "DELE FileTodelete.xml"

You place a command with -Q, but -DELE file is not a common ftp command. Try one of these instead:

curl -v -u username:pwd ftp://host/FileTodelete.xml -Q 'DELE FileTodelete.xml'
curl -v -u username:pwd ftp://host/FileTodelete.xml -Q 'DELETE FileTodelete.xml'
curl -v -u username:pwd ftp://host/FileTodelete.xml -Q 'rm FileTodelete.xml'

I accomplished this task by first logging into my FTP server then typing "?" at the command line to get a list of commands recognized by my FTP server. The command recognized by my server was "delete".

So, -Q"delete $fileToRemove" $serverURL

I was also able to get it to work by using -X"DELE $fileToRemove" $serverURL. However, I kept getting rc=19 (because I think the "-X" option mostly applies to HTTP|HTTPS?) from curl when I used this argument even though the file was successfully deleted.

Not sure if other FTP servers recognize different commands but this is what worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!