cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: I need help to use find and curl together to upload a directory

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Tue, 13 Aug 2013 10:42:00 +0200

On Tuesday 13 August 2013 01:35:02 Christoph Roland Murauer wrote:
> Am 12.08.2013 um 18:46 schrieb James Youngman <jay_at_gnu.org>:
> > I don't clearly understand the problem you are trying to describe (you
> > might find it helpful to review
> > http://www.catb.org/esr/faqs/smart-questions.html). Are you saying
> > that find launches curl with an incorrect command-line? If so, what
> > command-line did you want and what are you getting? If curl is being
> > launched with the command-line you expect, but you are not getting the
> > result you hope for, this is likely a problem that you should take up
> > with the curl user mailing list and/or developers.
>
> I don't know which part is the problem (find, curl or me). Maybe I kept my
> question a littlebit to short.
>
> > But since you are passing --ftp-create-dirs to curl, perhaps you don't
> > want to pass any directories as the expansion of {} when invoking
> > curl. If that's the case you could just put "-type f" on find's
> > command-line before the "-exec".
>
> I have on the FTP a directory call images.
>
> I have the following local structure which I want to upload (_site, css,
> images and posts are directories).
>
> _site
>
> |- archive.html
> |- css
> |
> | |- default.css
> |
> |- images
> |. |- whatever.png
> |- index.html
> |- posts
> |
> |- whatever.html
>
> After running (inside the _site directory)
>
> find . -exec curl --ftp-create-dirs -T {} -v -k -u user_at_name:password
> ftp://server/directory --ftp-ssl \;
>
> ... I had the following on the FTP.
>
> archive.html
> css
> default.css
> images
> whatever.png
> index.html
> posts
> whatever.html
>
> css and posts are created as empty files (like with touch) and not as
> directories like in the original structure. images is still a directory
> and untouched.
>
> Find should query the directory _site and forward the result to curl. Curl
> should upload everything and if it is a directory which doesn't exist on
> the FTP, then curl should creat it as a directory and not as a file.

It cannot work this way. The -T option of curl takes only one argument. You
need to call curl with multiple pairs of local/remote locations. Please have
a look at the curl.1 man page. You may also want to exclude the directories
from the list of files being transferred as James suggested.

Kamil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-08-13