cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to catch SFTP commands result ?

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 8 Mar 2012 23:58:43 +0100

On Thu, Mar 08, 2012 at 10:20:59PM +0000, muller_b wrote:
> I have a problem using libcurl as a SFTP client; I am pointing a path via the
> url and I would want to do operations on files.
> I am using curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &func) which allows me
> to get the file listing of the directory as text in my func method.
> This works, but when I send a command like curl_easy_setopt(curl,
> CURLOPT_QUOTE, "pwd") for instance, then I dont know where the data stream is
> redirected and it does not seem to be towards my func method.
> The CURLOPT_VERBOSE mode might be the source of what I can read in the shell
> (something like ">PWD \n< /printing/working/dir") but, in that case I would
> like to get the "/printing/working/dir" servers answer.

SFTP is a binary protocol, and libcurl doesn't provide access to the raw
commands and responses sent. Instead, it emulates FTP to some degree and
converts quote commands and responses into FTP-like text responses. You
should be able to access them in the same was as normal FTP headers,
that is, using the CURLOPT_HEADERFUNCTION callback function.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-08