1

I am trying to download a file from this site https://dev.bukkit.org/projects/economyshopgui. There is a button named "Download Latest File", so I copied the link to that button and pasted into the terminal with the following cURL command:

curl -o EconomyShopGUI.jar https://dev.bukkit.org/projects/economyshopgui/files/latest

and also tried the following command to see what it would download

curl -O https://dev.bukkit.org/projects/economyshopgui/files/latest

I tried to search some results online and to put curl -L -O or curl -O -J -L. I tried everything and maybe there is no way to do what I asked. Hope that someone could give me an explanation or solution. I can't download from browser because, so that's my only way to DL something.

Thank in advance

1 Answer 1

2

You need to include the -L, --location option:

curl -Lo EconomyShopGUI.jar https://dev.bukkit.org/projects/economyshopgui/files/latest

Explanation

The URL returns a 302 redirect to /error?aspxerrorpath=/projects/economyshopgui/files/latest. This can be seen by making a HEAD request instead of a GET request:

$ curl -I https://dev.bukkit.org/projects/economyshopgui/files/latest
HTTP/2 302
date: Wed, 17 Nov 2021 20:58:33 GMT
content-type: text/html; charset=utf-8
set-cookie: AWSALB=XPIy/kG6YB43FiNyWSi8BpsIA6YAUWahl8p7PGFVzlb3MOocdKfR/WUYuEZhMHDI0jX9fwmOYUZds4nzi/D8MJmmRH4j2/snJ9iFftX1dxsnm1ECV3YtsCf9nl2y; Expires=Wed, 24 Nov 2021 20:58:33 GMT; Path=/
cache-control: private
location: /error?aspxerrorpath=/projects/economyshopgui/files/latest
...

The -L, --location option instructs curl to follow such redirections:

If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place.

Alternative solution

You could use wget instead of curl:

 wget --content-disposition  https://dev.bukkit.org/projects/economyshopgui/files/latest

With the --content-disposition option, this automatically saves the output to EconomyShopGUI-3.9.2.jar. Without it, the resulting file would be saved with the not-very-useful name, latest.

1
  • The OP said they'd already tried -L and it didn't work for them
    – roaima
    Jan 1 at 0:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .