FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 05-09-2011, 10:36 AM
Alex Schuster
 
Default bash script error

Kfir Lavi writes:

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

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

> > > On 2011-05-09, Xi Shen <davidshen84@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
 
Old 05-09-2011, 10:45 AM
"JDM"
 
Default bash script error

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 <davidshen84@googlemail.com>
> wrote:

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

> > > On 2011-05-09, Xi Shen <davidshen84@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
 
Old 05-09-2011, 12:06 PM
Kfir Lavi
 
Default bash script error

On Mon, May 9, 2011 at 1:36 PM, Alex Schuster <wonko@wonkology.org> wrote:


Kfir Lavi writes:



> On Mon, May 9, 2011 at 12:00 PM, Xi Shen <davidshen84@googlemail.com>

> wrote:



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



> > > On 2011-05-09, Xi Shen <davidshen84@googlemail.com> wrote:



> > >> My script looks like:

> > >>

> > >> url="" href="http://mypage" target="_blank">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="" href="http://mypage" target="_blank">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
 
Old 05-09-2011, 12:57 PM
BRM
 
Default bash script error

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 <davidshen84@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/
>
>
 
Old 05-09-2011, 12:57 PM
BRM
 
Default bash script error

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 <davidshen84@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/
>
>
 
Old 05-09-2011, 02:16 PM
Kevin McCarthy
 
Default bash script error

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 <signals@gentoo.org>
 
Old 05-10-2011, 10:30 PM
David Haller
 
Default bash script error

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>
 
Old 05-10-2011, 10:57 PM
David Haller
 
Default bash script error

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??
 

Thread Tools




All times are GMT. The time now is 12:30 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org