cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Trouble Retrieving Header Data from SFTP Connection (Daniel Stenberg)

From: Christopher Gamio <cgamio_at_xceedium.com>
Date: Wed, 29 Dec 2010 17:41:18 -0500

On Dec 29, 2010, at 5:11 PM, curl-library-request_at_cool.haxx.se wrote:

> On Wed, 29 Dec 2010, Christopher Gamio wrote:
>
>> I'm working on a small project where I need to know the directory a (s)ftp
>> user is initial sent to. I achieved this in the case of an ftp server by
>> sending the "pwd" command, and creating a specialized header function to
>> parse the response. But unfortunately in the case of an sftp connection, my
>> header function does not receive any data.
>
> Ouch. You didn't mention which libcurl version you're using but I checked the
> code for this logic and...
>
>> In the case of an SFTP connection, I see the following lines:
>>
>> * Sending quote commands
>>> PWD
>> < 257 "/" is current directory.
>> Recieved Header Line: drwxr-xr-x 3 root root 4096 Sep 9 12:18 home
>>
>> It looks like for sftp connections the response is not being fed through the
>> header function like it is for ftp connection. Am I doing something wrong? I
>> searched through the mailing list archives and was able to find this thread
>> that describes the same issue, but it doesn't look like it was ever
>> resolved.
>>
>> http://curl.haxx.se/mail/lib-2009-11/0108.html
>
> No, I clearly dropped the ball and that one.
>
> I read up on the current code for 'pwd' (lib/ssh.c:1046 to 1056) and it quite
> clearly does not send the current path to the header callback. It is just sent
> to the debug output function, which allows you to trap it if you use
> CURLOPT_DEBUGFUNCTION but that really isn't what I thought or what I think is
> correct.
>
> This is a bug, we should fix it!
>
> --
>
> / daniel.haxx.se

I just downloaded the source and took at look at the file you mentioned and see what you mean that its just being sent to the debug output. I'm going to see if I can figure out how to implement actually returning the value and recompile.

Thanks for the speedy reply!
Chris Gamio
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-29