cURL / Mailing Lists / curl-library / Single Mail

curl-library

Ask for help to get sftp home directory

From: LIN Huangyang <Huangyang.Lin_at_alcatel-sbell.com.cn>
Date: Tue, 7 Dec 2010 11:29:11 +0800

Hi,

I'm using libcurl for both ftp & sftp operations. When I try to get
ftp/sftp home directory by code, I found different behaviors between ftp
& sftp.

Below is my sample code:

  struct curl_slist *headerlist=NULL;
  char buf [512] = "PWD"; // for sftp here is "pwd"

  headerlist = curl_slist_append(headerlist, buf);

  curl_easy_setopt(curl, CURLOPT_URL, my_url);
  curl_easy_setopt(_info->curl, CURLOPT_NOBODY, 1L);
  curl_easy_setopt(_info->curl, CURLOPT_QUOTE, headerlist);
  curl_easy_setopt(_info->curl, CURLOPT_VERBOSE, 1L);

Then I get below result in my console:

ftp:
257 "/home/user_name" is current directory.

sftp:
257 "/" is current directory.

But if I manually login to the remote server by ftp/sftp, then type
"pwd", I get "/home/user_name" as current dir for both cases.

Can you tell me why and help me to print out the correct sftp home
directory by code? Thanks a lot.

Regards
Lin Huangyang
8477-7571

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-07