cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Ask for help to get sftp home directory

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

From: curl-library-bounces_at_cool.haxx.se [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Daniel Stenberg
Sent: 2010Äê12ÔÂ7ÈÕ 16:20
To: libcurl development
Subject: Re: Ask for help to get sftp home directory

On Tue, 7 Dec 2010, LIN Huangyang wrote:

> curl_easy_setopt(curl, CURLOPT_URL, my_url);

What is the URL in the SFTP case?
[Lin Huangyang] The URL is sftp://xxx.xxx.xxx.xxx, without directory information.

> Then I get below result in my console:
>
> ftp:
> 257 "/home/user_name" is current directory.
>
> sftp:
> 257 "/" is current directory.

Surely sftp didn't mention 257?

> 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.

With libcurl you don't "login" to the site the same way your other clients may and I think that adds to the confusion.

With libcurl you specify a URL to libcurl and that includes (an implied or
explicit) directory. Directory treatment of URLs is quite different in FTP compared to SFTP URLs. In FTP you get the user's home directory by default if you don't explicilty ask for an absolute directory, in SFTP you get the root directory by default unless you explicilty ask for the user's home directory.

[Lin Huangyang] Do you mean that I have to explicitly add home directory to sftp URL in order to be at right place once connected? If I don't know the user home directory, is there other way to get to it when connected? Thanks.

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