CURL command line tool - Delete File from FTP server

前端 未结 3 1283
孤街浪徒
孤街浪徒 2021-01-17 20:57

I\'m actually trying to use CURL to make some operations on a ftp server in C++ with Visual Studio. I\'ve no trouble to do some uploads or downloads with comman

相关标签:
3条回答
  • 2021-01-17 21:10

    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'
    
    0 讨论(0)
  • 2021-01-17 21:14

    Problem solved! The dash before DELE should not be there:

    curl -v -u username:pwd ftp://host/FileTodelete.xml -Q "DELE FileTodelete.xml"
    
    0 讨论(0)
  • 2021-01-17 21:36

    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.

    0 讨论(0)
提交回复
热议问题