cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Implementing recursive SCP uploads

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 26 May 2010 11:09:07 +0200 (CEST)

On Wed, 26 May 2010, Nick Jensen wrote:

> Problem, the url
> "scp://localhost:22/folder-that-does-not-exist/some-file.txt" fails with:
> /folder-that-does-not-exist/some-file.txt
> No such file or directory
> Error in the SSH layer
> CURLE_SSH (79)
>
> So I obviously need to create this directory first if it does not exist. But
> I'm really not sure the best way to accomplish this. There doesn't seem to
> be any concept of QUOTE commands... Can someone point me in the direction of
> how I might (should) implement recursive SCP uploads?

It's not a problem that is very easy to solve.

A) SCP has no means to create directories, SCP is just a tiny tiny protocol
    that sends some instructions and then the raw binary stream. It even
    assumes that there is a scp executable in the other end that when run does
    the necessary remote SCP magic.

    In all practical ways, you can of course SSH to the same target and
    probably "mkdir" the missing dirs (as SCP is about as portable the
    existance of mkdir is), but that is of course a lot of assumptions. And
    libcurl currently doesn't actually do any plain SSH operations (even if
    libssh2 of course already provide the necessary set of functions to
    implement it).

B) SCP itself has a recursive option that allows a local SCP to send
    everything recursively to the remote site, and then the remote site creates
    the necessary directories etc. I don't remember exactly if libssh2 already
    supports this good enough, but it might not. And even if/when libssh2
    would support it, making sure that ability gets supported and possible to
    use by libcurl may not be as straight-forward as one would hope. I'm
    guessing a bit here since I haven't investigated the details on this.

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