curl-users
Re: curl and variables ?
Date: Mon, 7 Jul 2008 13:04:46 -0500
On Mon, Jul 7, 2008 at 12:43 PM, Patrik Martinsson <
martinsson.patrik_at_gmail.com> wrote:
> Hello everybody !
>
> I have a small problem, i donīt know whether its bash or curl or whats the
> problem, here is a small script i am intending to use for logging in to my
> bank and check my funds.
>
> #!/bin/bash
>
> curl -D cookie -A "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9)
> Gecko/2008051206 Firefox/3.0" "
> https://internetbank.swedbank.se/bviPrivat/privat?ns=1" # get to first
> page, save to cookie.
> newaddr=$(grep Location cookie | sed -e 's/^.* //') # get the adress from
> cookie
> curl -b cookie "$newaddr" # goto address in the variable ? this doesnt seem
> to work, why i really dont understand....I should get alot of html in
> response here, all i get is "curl: (52) Empty reply from server"
>
> I have been struggling with this now for a while, so all help would be much
> appriciated.
I just tried it and I don't see "Location" in the file called cookie, which
may be because I'm in the USA, not Sweden. However, if there *were* a
"Location:" header in that file, the best way to handle it would be to tell
curl to follow it:
curl -c cookie -L -A .....
https://internetbank.swedbank.se/bviPrivat/privat?ns=1
That'll make curl follow Location headers and store cookies in the cookie
file. Subsequently you'd use:
curl -b cookie -b cookie -L -A ........
so that curl will load and save cookies for you.
Ralph Mitchell
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-07-07