Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to download a file from a website which has a URL formatted like:

This redirects to a .zip file which has to be saved. There is also a need to authenticate based on username and password.

I tried to use wget, curl and lynx with no luck.


  • wget doesnt work with redirection. It simply downloads the webpage instead of the zip file.
  • curl gives the error "Maximum redirection exceeded > 50 "
  • lynx also gives the same error.
share|improve this question

migrated from Aug 9 '11 at 6:17

This question came from our site for professional and enthusiast programmers.

Are you getting errors or is it simply not working? – Jordan Aug 9 '11 at 5:18
How did you invoke lynx/curl/wget? What error did you get? – Noufal Ibrahim Aug 9 '11 at 5:19
I have updated the question.. – Vicky Aug 9 '11 at 5:44
If you have to log in and then the site redirects then you'll have to authenticate (submit your user/pass), probably a POST, then use the cookie the is returned in the next request. The curl error you're getting is probably you missing a parameter or cookie in the redirection (e.g. they set a Session cookie and you're not passing it on the redirection so it redirect you away, then redirect you back...infinite loop perhaps???). – Yzmir Ramirez Aug 9 '11 at 5:49
up vote 3 down vote accepted

Wget does support redirect, does this work?

wget --user=USER --password=PASS --max-redirect URL

Note that if the site does not implement HTTP Authentication (require a form submission via GET or POST), then you'll need to setup some more work (given the little information you give about the site where the file is, a good answer is hard to give)

wget --post-file=datafile --keep-session-cookies --max-redirect URL

and your datafile could look like


where username and password should be the name of the form fields being submitted.

NOTE : the site needs to redirect to the actual Zip file and not some other page where there is a link to the Zip file. If this is the case, you'll need to write a parsing script because neither Curl or Wget will help you there. They are tools to get content off of a given Url, they are not meant to "guess" you want you want them to fetch; they simply download what the server sends.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.