I am trying to download latest version of graphicsmagick from Sourceforge in my bash script
wget -q https://sourceforge.net/projects/graphicsmagick/files/latest/download?source=files -O GraphicsMagick-LATEST.tar.gz
tar -xzvf GraphicsMagick-LATEST.tar.gz
The problem is that when I try to extract the tar.gz I get the following error
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
This means that the script is not downloading the latest tar.gz but rather another filetype?
Why is that happening and what I am missing here?
Forget about my prevoius answer. The issue is not in the file. When you use wget with your current link, you are pointing to a sourceforge page. You are not downloading the file, but you are downloading the HTML page. Rename your file to
.html
and you can see all code of the sourceforge page.Will download an HTML.
The link you provide has a javascript redirect to the correct link depending in your operating system (as I have described in my other answer). But wget cannot execute this javascript code, therefore is not redirected. Still the link is inside the HTML. Search for the the next string:
And after this string, you can find the direct link to the last version:
(Note about that if you use the
--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0"
, the link is for thetar.gz
not for the.rpm
)You must therefore download the HTML file each time, search for the download link inside the HTML (with the currently latest version), and use it in a new
wget
command.