cURL / Mailing Lists / curl-users / Single Mail

curl-users

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

From: <paroxsitic_at_gmail.com>
Date: Fri, 21 Sep 2007 13:07:20 -0400

My problem was the $i inside the array

 ID=${textArray[$i]}

should be called liked:

 ID=${textArray[i]}

On 9/21/07, paroxsitic_at_gmail.com <paroxsitic_at_gmail.com> wrote:
> Here is the correct response if everything worked:
>
>
>
>
>
> * About to connect() to www.duels.com port 80
> * Trying 64.131.85.68... connected
> * Connected to www.duels.com (64.131.85.68) port 80
> > GET /challenges/skirmish/34 HTTP/1.1
> > 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=f129e8ba904b7cc49abc93a7b6872558;
> phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%22b10b8757c57f3764f8b7b8f69d969d48%22%3Bs%3A6%3A%22userid%22%3Bs%3A5%3A%2232214%22%3B%7D;
> Duels[UserId]=Q2FrZQ%3D%3D.qnXn5Gc%3D; CAKEPHP=9b0t0iaoeaafp3l0la2djoiic4
> >
> < HTTP/1.1 302 Found
> < Date: Fri, 21 Sep 2007 15:13:12 GMT
> < Server: Apache/2.0.52 (CentOS)
> < X-Powered-By: PHP/5.1.6
> < P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> < Location: /fights/narrate/12372126
> < Content-Length: 0
> < Content-Type: text/html; charset=UTF-8
> * Replaced cookie CAKEPHP="9b0t0iaoeaafp3l0la2djoiic4" for domain
> www.duels.com, path /, expire 0
> < Set-Cookie: CAKEPHP=9b0t0iaoeaafp3l0la2djoiic4; path=/
> * Replaced cookie CAKEPHP="9b0t0iaoeaafp3l0la2djoiic4" for domain
> www.duels.com, path /, expire 0
> < Set-Cookie: CAKEPHP=9b0t0iaoeaafp3l0la2djoiic4; path=/
> < Vary: Accept-Encoding
> * Connection #0 to host www.duels.com left intact
> * Issue another request to this URL:
> 'http://www.duels.com/fights/narrate/12372126'
> * Re-using existing connection! (#0) with host www.duels.com
> * Connected to www.duels.com (64.131.85.68) port 80
> > GET /fights/narrate/12372126 HTTP/1.1
> > 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=f129e8ba904b7cc49abc93a7b6872558;
> phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%22b10b8757c57f3764f8b7b8f69d969d48%22%3Bs%3A6%3A%22userid%22%3Bs%3A5%3A%2232214%22%3B%7D;
> Duels[UserId]=Q2FrZQ%3D%3D.qnXn5Gc%3D; CAKEPHP=9b0t0iaoeaafp3l0la2djoiic4
> >
> < HTTP/1.1 200 OK
> < Date: Fri, 21 Sep 2007 15:13:13 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-Type: text/html; charset=UTF-8
> < Vary: Accept-Encoding
> < Transfer-Encoding: chunked
> * Connection #0 to host www.duels.com left intact
> * Closing connection #0
>
>
> On 9/21/07, paroxsitic_at_gmail.com <paroxsitic_at_gmail.com> wrote:
> > Just as an update, it doesnt do the weird HTTP thing now:
> >
> > * About to connect() to www.duels.com port 80
> > * Trying 64.131.85.68... connected
> > * Connected to www.duels.com (64.131.85.68) port 80
> > > GET /challenges/skirmish/594 HTTP/1.1
> > > 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=51c9999ff7794c2fef15f65f9dec964a;
> >
> phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%22f984a282c436408712ee6e752d416da2%22%3Bs%3A6%3A%22userid%22%3Bs%3A5%3A%2232214%22%3B%7D;
> > Duels[UserId]=Q2FrZQ%3D%3D.%2BnG0Kl0%3D;
> CAKEPHP=on1e0oqhqjla1ib3hib9tagml7
> > >
> > < HTTP/1.1 200 OK
> > < Date: Fri, 21 Sep 2007 14:43:55 GMT
> > < Server: Apache/2.0.52 (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="on1e0oqhqjla1ib3hib9tagml7" for domain
> > www.duels.com, path /, expire 0
> > < Set-Cookie: CAKEPHP=on1e0oqhqjla1ib3hib9tagml7; path=/
> > < Vary: Accept-Encoding
> > * Connection #0 to host www.duels.com left intact
> > * Closing connection #0
> >
> >
> > On 9/21/07, paroxsitic_at_gmail.com <paroxsitic_at_gmail.com> wrote:
> > > I still can't get it to work. There was never a \r at the end to begin
> > > with. I confused the \n of the echo command and thought there was a
> > > \n.
> > >
> > > while read line
> > > do
> > > textArray[c]=$line
> > > echo "${textArray[c]} test ${textArray[c]}"
> > > c=$(expr $c + 1) # increase counter by 1
> > > done < $FILE
> > >
> > >
> > > Show that there is no return/newline after test in the echo.
> > >
> > > On 9/21/07, Ralph Mitchell <ralphmitchell_at_gmail.com> wrote:
> > > > On 9/21/07, paroxsitic_at_gmail.com <paroxsitic_at_gmail.com> wrote:
> > > > > You were correct. I was just finding that out when I got the email.
> I
> > > > > read the IDs from a file.
> > > > > I have stripped the \n this way:
> > > > >
> > > > > while read line
> > > > > do
> > > > > textArray[c]=$(echo $line | sed "s/\n//") # store line
> > > > > c=$(expr $c + 1) # increase counter by 1
> > > > > done < $FILE
> > > > >
> > > > > It seems slow, do you suggest a faster way to strip \n?
> > > > >
> > > >
> > > > You could try "tr -d '\r\n'" instead of sed. That's a smaller binary
> > > > and it's designed to just translate/delete characters. Sed does all
> > > > kinds of other stuff as well.
> > > >
> > > > Ralph Mitchell
> > > >
> > >
> >
>
Received on 2007-09-21