Wednesday, October 11, 2017

Automate download of patches from Oracle Support

If you need to download the patches or software from My Oracle Support, you can use the below utility available at Github

getMOSPatch

The Github site has instructions on how to use this utility.

I have found some additional challenges when using this utility if you are behind a proxy.

  • The way patch download process works is that you connect to MOS (support.oracle.com) using HTTPS for authentication and use http for actual file download. This requires you use the below command line argument to support for both http and https. The Github site readme only specifies using https, which works for authentication but fails to download the file.

java -Dhttp.proxyHost=aaa.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=aaa.com -Dhttps.proxyPort=80 -jar getMOSPatch.jar MOSUser=aaa@aaa.com MOSPass=aaa platform=226P download=all patch=26557153

  • I have also found that the code uses (Line 144) conn.setReadTimeout(60000); which is 1 minute. I have found that this may not be sufficient for the busy sites and it fails with the following message.  To avoid this issue, I simply changed it to conn.setReadTimeout(6000000); – 100 minutes and used the below to recompile the jar file.

Unzip the current jar to extract META-INF\MANIFEST.MF file to the folder where you store the java file. Also change the path to java. The below path are for Windows 8 and JDK 8.

"C:\Program Files\Java\jdk8\bin\javac.exe" -bootclasspath "C:\Program Files\Java\jdk8\jre\lib\rt.jar" -source 1.6 -target 1.6 getMOSPatch.java

"C:\Program Files\Java\jdk8\bin\jar.exe" cvmf META-INF/MANIFEST.MF getMOSPatch.jar getMOSPatch*.class

del *.class

Error Message if we do not change the setReadTimeout

Processing patch 26557153 for Linux x86-64 and applying regexp .* to the filenames:
  1 - p26557153_170151_Linux-x86-64.zip
  Enter Comma separated files to download: all
  All files will be downloadad because download=all was specified.

Downloading all selected files:
  java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read1(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)
        at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
        at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at java.net.HttpURLConnection.getResponseCode(Unknown Source)
        at getMOSPatch.getHttpInputStream(getMOSPatch.java:146)
        at getMOSPatch.DownloadFile(getMOSPatch.java:171)
        at getMOSPatch.DownloadAllFIles(getMOSPatch.java:498)
        at getMOSPatch.main(getMOSPatch.java:540)