rtrouton / rtrouton_scripts

Scripts to share
MIT License
1.3k stars 489 forks source link

Script now returning just HTML #59

Closed jmnielsen7 closed 5 years ago

jmnielsen7 commented 5 years ago

I can't say for sure if this is a 'just us' thing, but the IT team at my workplace has been using your awesome script for fetching the jdk (albeit a slightly older version of your script) for a while - thanks by the way! - but it stopped working a few weeks ago, I suspect because Oracle updated their pages.

I figured out that the main page it curls had changed its various jdk link URLs, compared to the older URL style parsed for in the script version we were using, to contain https instead of http, otn instead of otn-pub, and contained a new sequence of alphnumeric characters between forward slashes. I made the regex changes manually before discovering your latest script made the exact same change in the script for parsing the URLs. At least I was on the right track and got further... At that point I just downloaded and used your latest released script.

So I got past that point, but then I noticed that once it grabs the ultimate URL it wants to curl down into a DMG it's just pulling HTML and outputting it into the file whenever I try it.

I have mainly been testing that final step/curl by instantiating the values myself and typing it in as a one-liner on a bash shell, like this:

/usr/bin/curl --retry 3 -Lo "jdk.dmg" "https://download.oracle.com/otn/java/jdk/8u212-b10/59066701cf1a433da9770636fbc4c9aa/jdk-8u212-macosx-x64.dmg" -H "Cookie: oraclelicense=accept-securebackup-cookie"

I get a non-zero size file for the output of the curl which becomes the .dmg file, but what shows up as the contents of the .dmg file is the HTML for an oracle signon page which was captured in the curl:


<html>
<script language="javascript" type="text/javascript">
function submitForm()
{
var hash = location.hash;
if (hash) {
if(hash.indexOf("#") == -1){
hash="#"+hash
}
document.myForm.action = document.myForm.action+hash;
}
document.myForm.submit();
}
</script><head><base target="_self"></head><body onLoad="submitForm()"><noscript><p>JavaScript is required. Enable JavaScript to use OAM Server.</p></noscript><form action="https://login.oracle.com/mysso/signon.jsp" method="post" name="myForm"><!------------ DO NOT REMOVE -------------><!----- loginform renderBrowserView -----><!-- Required for SmartView Integration --><input type="hidden" name="bmctx" value="05C65B855F507509F2A50E4187F746B908003F815E8CAC65124394831AC5D9EF"><input type="hidden" name="contextType" value="external"><input type="hidden" name="username" value="string"><input type="hidden" name="contextValue" value="%2Foam"><input type="hidden" name="password" value="secure_string"><input type="hidden" name="challenge_url" value="https%3A%2F%2Flogin.oracle.com%2Fmysso%2Fsignon.jsp"><input type="hidden" name="request_id" value="5894995367757985692"><input type="hidden" name="authn_try_count" value="0"><input type="hidden" name="OAM_REQ" value="VERSION_4~… [Clipped for space reasons]…wHQ3o"><input type="hidden" name="locale" value="en"><input type="hidden" name="resource_url" value="https%253A%252F%252Fedelivery.oracle.com%252Fakam%252Fotn%252Fjava%252Fjdk%252F8u212-b10%252F59066701cf1a433da9770636fbc4c9aa%252Fjdk-8u212-macosx-x64.dmg"></form></body></html>

So, am I doing something wrong or is this happening for others as well?

-Josh

rtrouton commented 5 years ago

It looks like Oracle now has the Oracle JDK 8 downloads gated behind a login screen, so the script won't be able to get it. This is likely related to Oracle's recent license changes:

https://derflounder.wordpress.com/2018/10/19/oracle-java-jdk-openjdk-java-11-and-macos/

Screen Shot 2019-05-16 at 8 53 14 AM

jmnielsen7 commented 5 years ago

Well that's a mega bummer. But thanks for the response!