cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Curl sftp question...

From: James Housley <jim_at_thehousleys.net>
Date: Tue, 26 Jun 2007 13:14:33 -0400

On Jun 26, 2007, at 10:06 AM, Joe Ebmeier wrote:

> Hi,
>
> We are currently upgrading our version of curl to get sftp
> support for a .c program we use to move files around. I have tried
> using sftp from the .c program (using the curl libraries) and from
> the command line with the same results. With regular ftp, we were
> setting the “CURLOPT_FTPLISTONLY” flag (same as using a -l or --
> list-only from the command line) so we could use a wildcard to
> specify a file prefix. Sftp appears to be different in
> functionality, however, and I am having trouble finding helpful
> documentation. When I execute the same code with sftp, the command
> returns nothing. (If I get rid of the –l option on the command
> line, it lists the directory contents of the directory I was
> expecting.) If I use a wildcard, I get a message stating the file
> or directory does not exist. I just upgraded to curl version
> 7.16.3 yesterday and I am still having the same problems.
>
>
>
> Here is an example of what I was doing from the command line:
>
> When I execute:
>
> curl -l -u interact:password ftp://javadev2.interact.nonreg/lib/
>
> I get:
>
> libiicore.so
>
>
>
> When I execute:
>
> curl -l -u interact:password sftp://javadev2.interact.nonreg/
> interact/lib/
>
> I get nothing, but have a 0 return from curl.
>
>
>
> But when I execute:
>
> curl -u interact:password sftp://javadev2.interact.nonreg/
> interact/lib/
>
> I get:
>
> drwxr-xr-x 1 0 0 4096 Jun 7 9:52 .
>
> drwxr-xr-x 1 0 0 4096 Jun 7 9:52 ..
>
> -rwxrwxrwx 1 0 0 572486 Jun 7 9:54 libiicore.so
>
>
>
> Note: It appears that sftp wants the absolute path while ftp
> wants the path relative to the user’s home directory. That is why
> the first command only has /lib/ while the next two have /interact/
> lib/.
>
>
>
> So I guess I have these questions:
>
> 1.) Is there sftp specific documentation that might be able to
> help me?

The sftp:// and scp:// URLs are slightly different then those of
ftp://, http://tools.ietf.org/html/draft-ietf-secsh-scp-sftp-ssh-
uri-04 For example the ftp protocol is based on the directory you
login to. Where sftp is based on the whole file system. For example
to get the listing of the home directory for a user would be

curl -l -u interact:password sftp://javadev2.interact.nonreg/~/
>
>
> 2.) Any idea how to list the contents of a
> directory (using wildcards) with sftp?

Can't be done. The SFTP doesn't support that.
>
>
> 3.) If this functionality is not currently
> supported, any idea when it might be?

I don't believe the wild card listing is part of cURL, but part of
the FTP server on the other end. If it is in cURL, then it shouldn't
be too hard to add. If it is the FTP server, then someone would have
to write the code to support regular expressions for all the
platforms supported by cURL.

Jim

--
/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
  X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
                      http://www.FreeBSD.org     The Power to Serve
jim@TheHousleys.Net  http://www.TheHousleys.net
---------------------------------------------------------------------
Q: Because it reverses the logical flow of conversation.
A: Why is putting a reply at the top of the message frowned upon?
Received on 2007-06-26