Re: [gentoo-user] [OT] bash script error

2011-05-10 Thread David Haller
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??



Re: [gentoo-user] [OT] bash script error

2011-05-10 Thread David Haller
Hello,

On Mon, 09 May 2011, JDM wrote:
Do as you tried first, but add an eval:
eval curl $url -d \mydata\ $curl_opts

eval is evil ...

-dnh

-- 
Being disintegrated makes me ve-ry an-gry! huff, huff



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Nils Andresen
Hi,
have you tried /bin/bash -x your.script.sh - see what get's expanded ?

Nils

2011/5/9 Xi Shen davidshe...@googlemail.com

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.




Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Xi Shen
yes, you are right.

+ curl_opts='-x '\'''\'''

the -x '' expands to too many quotes. I tried to replace the
double-quotes to single-quotes, but still not working.

any idea how to fix this?


On Mon, May 9, 2011 at 2:43 PM, Nils Andresen n...@nils-andresen.de wrote:
 Hi,
 have you tried /bin/bash -x your.script.sh - see what get's expanded ?

 Nils

 2011/5/9 Xi Shen davidshe...@googlemail.com

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.





-- 
Best Regards,
Xi Shen (David)

http://twitter.com/davidshen84/



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Kfir Lavi
On Mon, May 9, 2011 at 9:43 AM, Nils Andresen n...@nils-andresen.de wrote:

 Hi,
 have you tried /bin/bash -x your.script.sh - see what get's expanded ?

 Nils


 2011/5/9 Xi Shen davidshe...@googlemail.com

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.

 You need to change:
- curl_opts=-x ''
+ curl_opts=-x 

Run your program with bash -x as Nils said, and you will see the expansion.

Kfir


Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Xi Shen
yes, i use the '-x' option, and i can see the expansion now. and i
found there are too many quotes.

i tried curl_opts=-x , does not work.


On Mon, May 9, 2011 at 3:52 PM, Kfir Lavi lavi.k...@gmail.com wrote:


 On Mon, May 9, 2011 at 9:43 AM, Nils Andresen n...@nils-andresen.de wrote:

 Hi,
 have you tried /bin/bash -x your.script.sh - see what get's expanded ?

 Nils

 2011/5/9 Xi Shen davidshe...@googlemail.com

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.

 You need to change:
 - curl_opts=-x ''
 + curl_opts=-x 

 Run your program with bash -x as Nils said, and you will see the expansion.

 Kfir




-- 
Best Regards,
Xi Shen (David)

http://twitter.com/davidshen84/



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Xi Shen
if i use -x '', or -x , it expands to -x. the quotes are removed as
they are empty.

if i use -x \'\', the expanded quotes are quoted again...resulting too
many quotes

it is driving me crazy o_O! please help.


On Mon, May 9, 2011 at 4:14 PM, Xi Shen davidshe...@googlemail.com wrote:
 yes, i use the '-x' option, and i can see the expansion now. and i
 found there are too many quotes.

 i tried curl_opts=-x , does not work.


 On Mon, May 9, 2011 at 3:52 PM, Kfir Lavi lavi.k...@gmail.com wrote:


 On Mon, May 9, 2011 at 9:43 AM, Nils Andresen n...@nils-andresen.de wrote:

 Hi,
 have you tried /bin/bash -x your.script.sh - see what get's expanded ?

 Nils

 2011/5/9 Xi Shen davidshe...@googlemail.com

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.

 You need to change:
 - curl_opts=-x ''
 + curl_opts=-x 

 Run your program with bash -x as Nils said, and you will see the expansion.

 Kfir




 --
 Best Regards,
 Xi Shen (David)

 http://twitter.com/davidshen84/




-- 
Best Regards,
Xi Shen (David)

http://twitter.com/davidshen84/



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Pandu Poluan
(Forgive my top-posting)

try:

curl_opts=-x \'\'

Rgds,


On 2011-05-09, Xi Shen davidshe...@googlemail.com wrote:
 yes, i use the '-x' option, and i can see the expansion now. and i
 found there are too many quotes.

 i tried curl_opts=-x , does not work.


 On Mon, May 9, 2011 at 3:52 PM, Kfir Lavi lavi.k...@gmail.com wrote:


 On Mon, May 9, 2011 at 9:43 AM, Nils Andresen n...@nils-andresen.de
 wrote:

 Hi,
 have you tried /bin/bash -x your.script.sh - see what get's expanded ?

 Nils

 2011/5/9 Xi Shen davidshe...@googlemail.com

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.

 You need to change:
 - curl_opts=-x ''
 + curl_opts=-x 

 Run your program with bash -x as Nils said, and you will see the
 expansion.

 Kfir




 --
 Best Regards,
 Xi Shen (David)

 http://twitter.com/davidshen84/




-- 
--
Pandu E Poluan - IT Optimizer
My website: http://pandu.poluan.info/



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Pandu Poluan
(Again, sorry for top-posting)

BTW, there are lots of bash gurus in stackovervlow.com. My handle
there is 'pepoluan'.

Rgds,


On 2011-05-09, Xi Shen davidshe...@googlemail.com 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 ''.

 But If I modify the script to:

 url=http://mypage;
 curl $url -d \mydata\ -x ''

 It works fine.

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.


 --
 Best Regards,
 Xi Shen (David)

 http://twitter.com/davidshen84/




-- 
--
Pandu E Poluan - IT Optimizer
My website: http://pandu.poluan.info/



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Xi Shen
i tried that already. not working. i will try the stackoverflow.com. thanks


On Mon, May 9, 2011 at 4:31 PM, Pandu Poluan pa...@poluan.info wrote:
 (Again, sorry for top-posting)

 BTW, there are lots of bash gurus in stackovervlow.com. My handle
 there is 'pepoluan'.

 Rgds,


 On 2011-05-09, Xi Shen davidshe...@googlemail.com 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 ''.

 But If I modify the script to:

 url=http://mypage;
 curl $url -d \mydata\ -x ''

 It works fine.

 I guess there's something wrong with the argument expansion. Just do
 not know how to fix it. Please help.


 --
 Best Regards,
 Xi Shen (David)

 http://twitter.com/davidshen84/




 --
 --
 Pandu E Poluan - IT Optimizer
 My website: http://pandu.poluan.info/





-- 
Best Regards,
Xi Shen (David)

http://twitter.com/davidshen84/



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Kfir Lavi
On Mon, May 9, 2011 at 12:00 PM, Xi Shen davidshe...@googlemail.com wrote:

 i tried that already. not working. i will try the stackoverflow.com.
 thanks


 On Mon, May 9, 2011 at 4:31 PM, Pandu Poluan pa...@poluan.info wrote:
  (Again, sorry for top-posting)
 
  BTW, there are lots of bash gurus in stackovervlow.com. My handle
  there is 'pepoluan'.
 
  Rgds,
 
 
  On 2011-05-09, Xi Shen davidshe...@googlemail.com 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 ''.
 
  But If I modify the script to:
 
  url=http://mypage;
  curl $url -d \mydata\ -x ''
 
  It works fine.
 
  I guess there's something wrong with the argument expansion. Just do
  not know how to fix it. Please help.
 
 
  --
  Best Regards,
  Xi Shen (David)
 
  http://twitter.com/davidshen84/
 
 
 
 
  --
  --
  Pandu E Poluan - IT Optimizer
  My website: http://pandu.poluan.info/
 
 



 --
 Best Regards,
 Xi Shen (David)

 http://twitter.com/davidshen84/

 I have replied you before.
What I have sent you is the solution to your problems.
Try to run what I told you.
I ran it successfully on my comp.
curl_opts=-x 

Kfir


Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Alex Schuster
Kfir Lavi writes:

 On Mon, May 9, 2011 at 12:00 PM, Xi Shen davidshe...@googlemail.com
 wrote:

  On Mon, May 9, 2011 at 4:31 PM, Pandu Poluan pa...@poluan.info wrote:

   On 2011-05-09, Xi Shen davidshe...@googlemail.com wrote:

   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 ''.
   
   But If I modify the script to:
   
   url=http://mypage;
   curl $url -d \mydata\ -x ''
   
   It works fine.
   
   I guess there's something wrong with the argument expansion. Just do
   not know how to fix it. Please help.

Do as you tried first, but add an eval:
eval curl $url -d \mydata\ $curl_opts

  I have replied you before.
 
 What I have sent you is the solution to your problems.
 Try to run what I told you.
 I ran it successfully on my comp.
 curl_opts=-x 

This gives a command not found error, as bash tries to execute the empty 
command . Are you using another shell?

Wonko



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread JDM
He

--Original Message--
From: Alex Schuster
To: gentoo-user@lists.gentoo.org
ReplyTo: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] [OT] bash script error
Sent: 9 May 2011 11:36

Kfir Lavi writes:

 On Mon, May 9, 2011 at 12:00 PM, Xi Shen davidshe...@googlemail.com
 wrote:

  On Mon, May 9, 2011 at 4:31 PM, Pandu Poluan pa...@poluan.info wrote:

   On 2011-05-09, Xi Shen davidshe...@googlemail.com wrote:

   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 ''.
   
   But If I modify the script to:
   
   url=http://mypage;
   curl $url -d \mydata\ -x ''
   
   It works fine.
   
   I guess there's something wrong with the argument expansion. Just do
   not know how to fix it. Please help.

Do as you tried first, but add an eval:
eval curl $url -d \mydata\ $curl_opts

  I have replied you before.
 
 What I have sent you is the solution to your problems.
 Try to run what I told you.
 I ran it successfully on my comp.
 curl_opts=-x 

This gives a command not found error, as bash tries to execute the empty 
command . Are you using another shell?

Wonko



Sent from my BlackBerry® wireless device

Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Kfir Lavi
On Mon, May 9, 2011 at 1:36 PM, Alex Schuster wo...@wonkology.org wrote:

 Kfir Lavi writes:

  On Mon, May 9, 2011 at 12:00 PM, Xi Shen davidshe...@googlemail.com
  wrote:

   On Mon, May 9, 2011 at 4:31 PM, Pandu Poluan pa...@poluan.info
 wrote:

On 2011-05-09, Xi Shen davidshe...@googlemail.com wrote:

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 ''.
   
But If I modify the script to:
   
url=http://mypage;
curl $url -d \mydata\ -x ''
   
It works fine.
   
I guess there's something wrong with the argument expansion. Just do
not know how to fix it. Please help.

 Do as you tried first, but add an eval:
 eval curl $url -d \mydata\ $curl_opts

   I have replied you before.
 
  What I have sent you is the solution to your problems.
  Try to run what I told you.
  I ran it successfully on my comp.
  curl_opts=-x 

 This gives a command not found error, as bash tries to execute the empty
 command . Are you using another shell?

Wonko

 Sorry,
I have put www.google.com in th url, so got the page, and didn't notice the
error. hehe

Kfir


Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread BRM
Well, I saw a lot of advice on this but no real solution - just some debugging 
help.

At least from my own experience with Bash Scripting, I find that you can never 
use enough braces when referencing variables.

So, the script should read:

url=http://mypage;
curl_opts=-x
curl ${url} -d \mydata\ ${curl_opts}


I would probably even go one further and use quotes in the final line as well, 
thus producing:

curl ${url}-d \mydata\ ${curl_opts}

Please note that the single and double quotes have meanings as far as expansion.

Also, the guys on IRC (#bash) are quite helpful - a great resource in addition 
to 'man bash'.

$0.02

Ben


- Original Message 
 From: Xi Shen davidshe...@googlemail.com
 To: gentoo-user gentoo-user@lists.gentoo.org
 Sent: Mon, May 9, 2011 1:44:58 AM
 Subject: [gentoo-user] [OT] bash script error
 
 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 ''.
 
 But If I modify the  script to:
 
 url=http://mypage;
 curl $url -d \mydata\ -x ''
 
 It works  fine.
 
 I guess there's something wrong with the argument expansion. Just  do
 not know how to fix it. Please help.
 
 
 -- 
 Best Regards,
 Xi  Shen (David)
 
 http://twitter.com/davidshen84/
 
 



Re: [gentoo-user] [OT] bash script error

2011-05-09 Thread Kevin McCarthy
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:

curl_opts=(-x )
curl $url -d \mydata\ ${curl_opts[@]}

But I'm sure there's a quotes-only solution, too. 

-- 
Kevin McCarthy sign...@gentoo.org



[gentoo-user] [OT] bash script error

2011-05-08 Thread Xi Shen
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 ''.

But If I modify the script to:

url=http://mypage;
curl $url -d \mydata\ -x ''

It works fine.

I guess there's something wrong with the argument expansion. Just do
not know how to fix it. Please help.


-- 
Best Regards,
Xi Shen (David)

http://twitter.com/davidshen84/