I need to be able to delete and rename files using ftp via libcurl.

I can do this with:

curl_easy_setopt(curl, CURLOPT_URL,ftp://<host>/);
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
cmdlist = curl_slist_append(cmdlist, "DELE /c/temp/ftp/a.txt");
curl_easy_setopt(curl, CURLOPT_QUOTE, cmdlist);
res = curl_easy_perform(curl);

however after running the DELE command, curl also performs a LIST which I do 
not want since this could be the LIST of a large folder.

I have tried to replace the LIST with another command, for example NOOP, and 
whilst this then runs the NOOP, it fails saying that the RETR failed:

> DELE /c/temp/ftp/a.txt
* ftp_perform ends with SECONDARY: 0
< 250 DELE command successful.
> EPSV
* Connect data stream passively
< 229 Entering Extended Passive Mode (|||58676|)
> TYPE A
< 200 Type set to A.
> NOOP
< 200 NOOP command successful.
* RETR response: 200
curl rc 19 FTP: couldn't retrieve (RETR failed) the specified file

I have seen another thread which says that the resolution would to remove the 
CURLOPT_URL, but I don't know who this could work since this option specifies 
the connect host.

I can leave this code as-is and ignore rc19, but this is not elegant, so 
looking for a better solution to allow me to run commands on the FTP server 
without listing the folder contents or having it issue the unwanted RETR.

Thanks,
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to