cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to delete file from sftp server by libcurl

From: »ÆÐÄâù <e_balloon_at_163.com>
Date: Thu, 20 Sep 2012 11:29:00 +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?

Besides, I have try CString cmd = "rm 2.key", CString cmd = "DELE 2.key", which leads to the same result.

Many thanks.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-20