1 |
Hello, |
2 |
|
3 |
On Mon, 09 May 2011, Kevin McCarthy wrote: |
4 |
>On Mon, May 09, 2011 at 01:44:58PM +0800, Xi Shen wrote: |
5 |
>> It is not specific to Gentoo. But do not know where to search or post it :) |
6 |
>> |
7 |
>> My script looks like: |
8 |
>> |
9 |
>> url="http://mypage" |
10 |
>> curl_opts="-x ''" |
11 |
>> curl $url -d \"mydata\" $curl_opts |
12 |
>> |
13 |
>> If I execute it, I got an error from curl, saying it cannot resolve |
14 |
>> the proxy ''. |
15 |
>> |
16 |
> |
17 |
>While bash arrays probably aren't required for this, the following seems |
18 |
>to work OK: |
19 |
|
20 |
When using the bash anyway, arrays are the thing to use! |
21 |
|
22 |
>curl_opts=(-x "") |
23 |
>curl $url -d \"mydata\" "${curl_opts[@]}" |
24 |
> |
25 |
>But I'm sure there's a quotes-only solution, too. |
26 |
|
27 |
I can't find one. Seems to be some curl weirdness layered on top. Even |
28 |
with |
29 |
strace -eexecve curl "$url" -d "mydata" $curl_opts |
30 |
and (quoted, escaped etc.) variations thereof, I haven't found a |
31 |
version that works. |
32 |
|
33 |
If you want to just DL some stuff, with POST, no proxy, why not use |
34 |
wget? |
35 |
|
36 |
wget --post-data="mydata" --no-proxy "$url" |
37 |
|
38 |
(and if you want the result on stdout, just add '-O -', i.e.: |
39 |
|
40 |
wget --post-data="mydata" --no-proxy -O - "$url" |
41 |
|
42 |
). Or if you want the options as such: |
43 |
|
44 |
url=... |
45 |
wget_opts="--no-proxy -O -" ### special chars need to be |
46 |
### once-escaped when using |
47 |
### options/arguments with spaces, |
48 |
### quotes etc. |
49 |
post_data="foo=bar" |
50 |
set -x |
51 |
wget ${wget_opts} --post-data="$post_data" "$url" |
52 |
### ^^^^^^^^^^^^ no quotes here, or use an array! |
53 |
|
54 |
HTH, |
55 |
-dnh |
56 |
|
57 |
-- |
58 |
Doesn't it bother you, that we have to search for intelligent life |
59 |
--- OUT THERE?? |