Hello,

On Mon, 09 May 2011, Kevin McCarthy wrote:
>On Mon, May 09, 2011 at 01:44:58PM +0800, Xi Shen wrote:
>> It is not specific to Gentoo. But do not know where to search or post it :)
>> 
>> My script looks like:
>> 
>> url="http://mypage";
>> curl_opts="-x ''"
>> curl $url -d \"mydata\" $curl_opts
>> 
>> If I execute it, I got an error from curl, saying it cannot resolve
>> the proxy ''.
>> 
>
>While bash arrays probably aren't required for this, the following seems
>to work OK:

When using the bash anyway, arrays are the thing to use!

>curl_opts=(-x "")
>curl $url -d \"mydata\" "${curl_opts[@]}"
>
>But I'm sure there's a quotes-only solution, too. 

I can't find one. Seems to be some curl weirdness layered on top. Even
with
    strace -eexecve curl "$url" -d "mydata" $curl_opts
and (quoted, escaped etc.) variations thereof, I haven't found a
version that works.

If you want to just DL some stuff, with POST, no proxy, why not use
wget?

    wget --post-data="mydata" --no-proxy "$url"

(and if you want the result on stdout, just add '-O -', i.e.:

    wget --post-data="mydata" --no-proxy -O - "$url"

). Or if you want the options as such:

    url=...
    wget_opts="--no-proxy -O -" ### special chars need to be
                                ### once-escaped when using
                                ### options/arguments with spaces,
                                ### quotes etc.
    post_data="foo=bar"
    set -x
    wget ${wget_opts} --post-data="$post_data" "$url"
    ###  ^^^^^^^^^^^^ no quotes here, or use an array!

HTH,
-dnh

-- 
Doesn't it bother you, that we have to search for intelligent life 
--- OUT THERE??

Reply via email to