curl-library
How to capture the STAT output in a variable ?
Date: Wed, 17 Dec 2008 17:10:01 +1100
Hi,
I CWD to a directory and use STAT *.* command to get the list of all the
files in the directory printed in the stdout .But is there any way I can
store this result in a variable.
Please find the code snippet below:
Thanks in advance.....
#define REMOTE_URL "ftp://user:Password@10.20.30.21/FTPTest"
#define DEST_FILE_IN "/FTPTest/folder"
using namespace std;
int main(int argc, char **argv)
{
CURL *curl;
CURLcode res;
CURLcode res2;
memset(buf_1, 0, sizeof(buf_1));
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
/* CWD to change the directory */
curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
sprintf(buf_1, "CWD %s" ,DEST_FILE_IN );
headerlist = curl_slist_append(headerlist, buf_1);
curl_easy_setopt(curl, CURLOPT_QUOTE, headerlist);
res = curl_easy_perform(curl);
/* Reinitialize the list */
headerlist =NULL;
memset(buf_1, 0, sizeof(buf_1));
/*Size of the specific file */
sprintf(buf_1, "STAT *.*" );
curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&response);
headerlist = curl_slist_append(headerlist, buf_1);
curl_easy_setopt(curl, CURLOPT_QUOTE, headerlist);
res2 = curl_easy_perform(curl);
curl_slist_free_all (headerlist);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
Karthik Sundaravadivelu
Nielsen Loyalty System
The Nielsen Company
Phone : (612) 8873 7429
Fax (612) 8873 7333
www.nielsen.com
Received on 2008-12-17