tags:

views:

164

answers:

3

Hello,

I need to use libcurl for creating a folder in my home directory. I use the following set of code for this:

struct curl_slist *headers = NULL; 
headers = curl_slist_append(headers, "mkdir MyFolder"); 
curl_easy_setopt(curl, CURLOPT_QUOTE, headers); 

I have given the ftp server-path, user name, password. But, I get the error '500 COmmand not understood'.

I tried using 'pwd' command instead of 'mkdir MyFolder'. It worked without any error.

Can some one help me out to solve this problem.

Thanks in advance.

+2  A: 

You should probably use MKD instead of mkdir.

See FILE TRANSFER PROTOCOL (FTP) RFC0959.

Ross
@Judge Maygarden Thanks for adding the link and covering up my laziness ;)
Ross
A: 

Since MKD (MKDIR) is an optional command in the FTP protocol, maybe the FTP server is configured not to allow it? Can you do the MKD on the target server when you connect manually?

Jonathan Leffler
A: 

The MKD command worked fine when I used 'CURLOPT_CUSTOMREQUEST' command instead of CURLOPT_QUOTE.

The code:

curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "MKD home-directory-path/new_directory_name");

The directory gets created in the specified path. But, the result of curl_easy_perform is CURLE_FTP_COULDNT_RETR_FILE. When I enabled verbose option, I noticed that libcurl executes RETR(retrieve command) after directory creation.

Why is RETR command executed and how to solve this error?

Can someone help me out to come out from this problem.

Thanks in advance.

Deepa