cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Linux: curl command doesnt like the use of ${} in bash.

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Fri, 21 Sep 2007 08:44:18 -0500

On 9/21/07, Brian Hare <paroxsitic_at_gmail.com> wrote:
> This is the code:
>
> ID=${textArray[$i]}
> curl -v -L -b cookies.txt
> "http://www.duels.com/challenges/skirmish/$ID" > scrim.html
>
> This is the verbose output:
>
>
> HTTP/1.1allenges/skirmish/594
> > User-Agent: curl/7.15.5 (i486-pc-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8c zlib/1.2.3 libidn/0.6.5
> > Host: www.duels.com
> > Accept: */*
> > Cookie: phpbb2mysql_sid=fffcbc5cf2d66a87eb166f744ddf019d; phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%223e76a55dc717101124a0a1cac78d80a4%22%3Bs%3A6%3A%22userid%22%3Bs%3A5%3A%2232214%22%3B%7D; Duels[UserId]=Q2FrZQ%3D%3D.qnXn5Gc%3D; CAKEPHP=7fjnvp2gaij0jqibcu6vkt4eu6
> >
> < HTTP/1.1 200 OK
> < Date: Fri, 21 Sep 2007 13:21:32 GMT
> < Server: Apache/2.0.59 (CentOS)
> < X-Powered-By: PHP/5.1.6
> < P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> < Content-Length: 0
> < Content-Type: text/html; charset=UTF-8
> * Replaced cookie CAKEPHP="7fjnvp2gaij0jqibcu6vkt4eu6" for domain
> www.duels.com, path /, expire 0
> < Set-Cookie: CAKEPHP=7fjnvp2gaij0jqibcu6vkt4eu6; path=/
> < Vary: Accept-Encoding
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 0 0 0 0 0 0 0 0 --:--:-- --:--:--
> --:--:-- 0* Connection #0 to host www.duels.com left intact
>
> * Closing connection #0
>
>
>
> Notice the HTTP/1.1allenges/skirmish/594. 594 is $ID but the
> allenges is where the error occurs. If I manually change the code to:
>
> curl -v -L -b cookies.txt
> "http://www.duels.com/challenges/skirmish/594" > scrim.html
>
> Then it works perfectly and it displays HTTP/1.1 /challenges/skirmish/594.
>
>
> Does anyone know what my problem is, and if there is a workaround to this?

Humour me and try doing:

    echo "$ID" | od -c

and see if there's a carriage return following the number. You output
*should* have looked like this:

     curl -v http://localhost/hobbit
     * About to connect() to localhost port 80
     * Trying 127.0.0.1... connected
     * Connected to localhost (127.0.0.1) port 80
> GET /hobbit HTTP/1.1

with the "HTTP/1.1" on the end of the line, instead of at the start.
This suggests a carriage return in the $ID string...

Ralph Mitchell
Received on 2007-09-21