curl-users
Re: Wildcards in ftp file uploads
Date: Wed, 12 Jun 2013 12:22:30 -0400
First: I hope I'm replying to this correctly, I haven't used a mailing
list in years, so apologies if this ends up somewhere it isn't
supposed to.
> I don't think this is correct. Since you've not quoted the glob, your
> shell expands it to one or more words before curl sees it. You're
> essentially passing the following commandline to curl, which you'll see
> is not what you want:
>
> curl -v ftp://1.1.1.1 -u user:Pass -T test.txt test2.txt ftp://1.1.1.1
>
> What you meant to write is:
>
> curl -v ftp://1.1.1.1 -u user:Pass -T "*.txt" ftp://1.1.1.1
>
> The remainder of your analysis is also incorrect based on this same
> mistake.
I tried placing the file name in quotes per this suggestion, and
nothing was uploaded. Single, precise file names work fine inside
double or single quotes. Nothing with a wildcard in it seems to work
though, including previous examples that would upload single files.
>
>
> curl(1) is non-direct about its use of quoting for the -T option, but
> it's very clear that you can specify the -T option multiple times if you
> instead want to expand the globs yourself. You could do something like
> (in bash):
>
> uploads=()
> for f in *.txt; do
> [[ -e $f ]] && uploads+=(-T "$f")
> done
>
> if (( ${#uploads[*]} )); then
> curl -v ftp://1.1.1.1 -u user:Pass "${uploads[@]}" ftp://1.1.1.1
> fi
>
I'm going to try working with this and I'll let everyone know how it
turns out. I'm not the best at scripting so it may take a while.
In the mean time, if anyone has any other insights into using wild
cards let me know. I'd still like to know if this was intended
implemented behavior or not.
Thanks for the quick reply Dave.
-------------------------------------------------------------------
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-06-12