curl-users
How to delete file from sftp server by libcurl
Date: Wed, 19 Sep 2012 19:16:06 +0800 (CST)
Hi,
I am trying to delete a file from sftp server. Here is my code:
CString cmd = "delete 2.key";
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD);
curl_easy_setopt(curl, CURLOPT_USERPWD, myUserPass.c_str());
curl_easy_setopt(curl, CURLOPT_URL, myUrl.c_str());
curl_easy_setopt(curl, CURLOPT_PORT, atoi(m_port.c_str()));
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, cmd.c_str());
CURLcode nRet = curl_easy_perform(curl);
curl_easy_cleanup(curl);
As a result, the interface curl_easy_perform() return CURLE_OK, but file 2.key is not deleted, what is more the interface list the file as:
drw-rw-rw 1 root root 0 Sep 20 03:13 .
drw-rw-rw 1 root root 0 Sep 20 03:13 ..
-rw-rw-rw 1 root root 530 Sep 20 03:13 1.key
-rw-rw-rw 1 root root 530 Sep 20 03:13 2.key
drw-rw-rw 1 root root 0 Sep 20 00:41 79G
I think I need your help here, how can I delete 2.key by libcurl, since we can list the file here?
If I fail to delete it, is there any way not to list the files?
Many thanks.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-19