gunslingor
gunslingor

Reputation: 1486

How to download JRE packages via batch script

Oracle JRE

At the above link, I would like to download jre-8u211-windows-i586.tar.gz and jre-8u211-windows-x64.tar.gz via the windows command prompt or batch file. This is an interesting challenge for the batch expert, not sure how to deal with Oracles authentication either.

This is part of a batch script we have for reducing the size of our JRE distribution.

Upvotes: 0

Views: 836

Answers (1)

Sascha
Sascha

Reputation: 1343

As a starting point I can provide a Shell download script which looks for the newest Java 8 Server JRE:

downloadPage=$(wget -q -O- http://www.oracle.com/technetwork/java/javase/downloads/index.html | grep -o -E 'server-jre8-downloads-[^"]+.html')
echo Prüfe ${downloadPage} auf Download-Link
#downloadUrl=$(wget -q -O- http://www.oracle.com/technetwork/java/javase/downloads/${downloadPage} | grep -o -E "http.+/server-jre.+linux-x64.tar.gz" | head -1)
downloadUrl=$(wget -q -O- http://www.oracle.com/technetwork/java/javase/downloads/${downloadPage} | grep -o -E 'http[^"]+/server-jre[^"]+linux-x64.tar.gz' | head -1)

echo Download von ${downloadUrl}
downloadFileName=$(echo ${downloadUrl} | cut -d'/' -f9)
echo Dateiname ${downloadFileName}
version=$(echo ${downloadFileName} | cut -d'-' -f3 | cut -d'u' -f2)
echo Update-Version ${version}

tarDir=/usr/local/src

wget -P $tarDir --no-check-certificate --header='Cookie: oraclelicense=accept-securebackup-cookie' ${downloadUrl}

Upvotes: 2

Related Questions