C
C
ComradeTilde2022-04-13 20:40:19
Command line
ComradeTilde, 2022-04-13 20:40:19

CURL | How to download without knowing the version?

There is a link
github.com/adoptium/temurin8-binaries/releases/latest/OpenJDK8U-jdk_x64_windows_hotspot_8u322b06.msi
you need to make it so that instead of 8u322b06 you write something like %% and that this file is downloaded

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
rPman, 2022-04-13
@rPman

it won’t work with one request, moreover, you need a mini program to get what you want, it’s more difficult on bash than on something more convenient (php / js / ...)
you need to get a list of releases of the selected repository, take the first link and download it already
in your example to get list in json format:

curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/adoptium/temurin8-binaries/releases?per_page=1

here the parameter per_page=1 to give out only one release - the last one, if removed, will be given up to 30 pieces and can be loaded page by page
in the json response, take the desired link [x].assets[y].browser_download_url
where x is the number in the list of release versions and y is the number in the list of files , of
course, among the files, look for the name you need

M
mureevms, 2022-04-14
@mureevms

In the Linux console, you can do this, bring it under Windows yourself, I don’t know how to use it

# Выяснить длинную версию последнего релиза:
LONG_VERSION=$(curl -s https://github.com/adoptium/temurin8-binaries/releases/latest | awk -F\" {'print $2'} | awk -F/ {'print $8'})

# Привести длинную версию последнего релиза к короткой:
SHORT_VERSION=$(echo $LONG_VERSION | awk -F- {'print $1$2'} | sed 's/jdk//')

# Скачать файл:
wget https://github.com/adoptium/temurin8-binaries/releases/download/$LONG_VERSION/OpenJDK8U-jdk_x64_windows_hotspot_$SHORT_VERSION.msi

S
Saboteur, 2022-04-14
@saboteur_kiev

get download link:

curl https://api.github.com/repos/adoptium/temurin8-binaries/releases/latest?per_page=1|grep -oP 'download_url": "\K.*OpenJDK8U-jdk_x64_windows_hotspot.*msi(?=")'

then you can put it in a variable:
URL=$(curl https://api.github.com/repos/adoptium/temurin8-binaries/releases/latest?per_page=1|grep -oP 'download_url": "\K.*OpenJDK8U-jdk_x64_windows_hotspot.*msi(?=")')
curl -OL $URL

or in xargs
curl https://api.github.com/repos/adoptium/temurin8-binaries/releases/latest?per_page=1|grep -oP 'download_url": "\K.*OpenJDK8U-jdk_x64_windows_hotspot.*msi(?=")'|xargs curl -OL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question