cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Help w/ using curl!

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 14 Sep 2001 10:07:18 +0200 (MET DST)

On Thu, 13 Sep 2001, Radi Shourbaji wrote:

> I currently use a Web based application via an ASP. The entire
> application runs secured using SSL. I am looking for help using curl to
> login to this website specifying a username and password, then open a URL
> that causes a CSV formatted report file to be generated and downloaded.
> And I want to do this all from a W2K platform in a totally automated
> fashion.

> After spending several hours last night tinkering with various
> combinations of the curl options, I was unsuccessful in coming up with
> the right combination to do this from the command line.

First, you need to get a basic idea on what you're up against. I suggest
reading "The Art Of Stricpting HTTP Requests Using Curl":
http://curl.haxx.se/docs/httpscripting.shtml

Then, without knowing much details of what you're doing, this is what I
suggest:

1. Login

 You don't mention what kind of login the site uses, so I'm gonna assume that
 it isn't a normal HTTP Authorization (curl -u) we're talking about, but a
 HTML form to fill in.

 You should most likely study the HTML and add all fields using curl -d
 arguments to post the login. The site might then redirect you to another
 page and/or send back cookies to use in future requests. Use -L to follow
 redirects and use "-b -' to enable the cookie awareness straight away. To
 be able to use the cookies in a subsequent download call you should probably
 also dump all headers to a file so that you can re-use the cookies later.
 Use '-D file' for that.

 Some "login"-systems use variables in the URL to keep state information.
 Then you need to pass that on to the URL in the following section:

2. Get the file

 Use '-b file' to tell curl where to read cookies from to use in the request.
 The URL to use can be static or it can depend on some kind of login id or
 state id. I cannot possibly know.

> I would appreciate receiving an example of how to do this as soon as
> possible!

We would need much more specific details to be able to suggest detailed
command lines.

Good luck!

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-09-14