0

I want to get a file downloaded on my linux system whose url is

http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-i586.tar.gz  

and I am issuing the following command as :

wget -U 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:16.0) Gecko/20100101 Firefox/16.0' http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-i586.tar.gz

whereas the user agent is being passed to -U which i have copied from my browser's user agent. But it downloads the file only of size 5.3KB whereas entire file is 46.09MB and the downloaded file is corrupted.

How can I resolve this issue?

Bohemian
  • 412,405
  • 93
  • 575
  • 722
user1708240
  • 315
  • 2
  • 6
  • 16
  • possible duplicate of [How to automate download and instalation of Java JDK on Linux?](http://stackoverflow.com/questions/10268583/how-to-automate-download-and-instalation-of-java-jdk-on-linux) – Alex Poole Jan 29 '14 at 12:52

2 Answers2

1

Looking at the output, you will realize that oracle denied the request, containing following message:

In order to download products from Oracle Technology Network you must agree to the OTN license terms.

Be sure that...

  • Your browser has "cookies" and JavaScript enabled.
  • You clicked on "Accept License" for the product you wish to download.
  • You attempt the download within 30 minutes of accepting the license.

Most probably you have to send some GET or POST value and/or keep session data.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
0

The file isn't 'corrupt' exactly; if you go to that URL in a new browser session you'll see an error page saying 'In order to download products from Oracle Technology Network you must agree to the OTN license terms.'. That is the page you've downloaded - the file size of the page it redirects to is 5307 bytes.

Before you can get the file from the download page you have to accept the license agreement using the radio buttons. Doing so creates a cookie in your browser, and when you get the actual file that cookie is checked. wget doesn't have that cookie available.

You need to download directly from the site, or arrange for wget to send a fake cookie, which probably isn't supported in general. Some downloads used to have a wget script attached, not sure if this one does; it doesn't look like it from what's on the download page.

Alex Poole
  • 183,384
  • 11
  • 179
  • 318