How do I download a file from SourceForge with wget?
Asked Answered
B

3

8

I am writing a script which needs to download a release file from sourceforge. How to get the good link?

The same question and its answer was given here in 2013, but it does not work anymore. https://unix.stackexchange.com/questions/86971/how-do-i-download-from-sourceforge-with-wget

$ wget 'http://downloads.sourceforge.net/project/romfs/genromfs/0.5.2/genromfs-0.5.2.tar.gz'
Saving to: ‘download?use_mirror=vorboss.html’

Update: log following @vookimedlo's answer:

$ ls -ld $(which wget)
lrwxr-xr-x  1 david  admin  30 Mar 29 16:17 /usr/local/bin/wget -> ../Cellar/wget/1.19.1/bin/wget

$ wget --version
GNU Wget 1.19.1 built on darwin16.4.0.

-cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls
+ntlm +opie -psl +ssl/openssl

Wgetrc:
    /Users/david/.wgetrc (user)
    /usr/local/etc/wgetrc (system)
Compile:
    clang -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc"
    -DLOCALEDIR="/usr/local/Cellar/wget/1.19.1/share/locale" -I.
    -I../lib -I../lib -I/usr/local/opt/openssl/include -DNDEBUG
Link:
    clang -DNDEBUG -liconv -L/usr/local/opt/openssl/lib -lssl -lcrypto
    -ldl -lz ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a


$ wget --content-disposition -c  https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2
--2017-07-25 10:55:27--  https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2
Resolving sourceforge.net... 216.34.181.60
Connecting to sourceforge.net|216.34.181.60|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 302 Found
  Server: nginx
  Date: Tue, 25 Jul 2017 08:55:28 GMT
  Content-Type: text/html; charset=UTF-8
  Content-Length: 365
  Connection: close
  Pragma: no-cache
  Cache-Control: no-cache
  X-UA-Compatible: IE=edge,chrome=1
  X-Frame-Options: SAMEORIGIN
  Content-Security-Policy: upgrade-insecure-requests
  Set-Cookie: VISITOR=2b8474db-e3d7-4710-8a3d-974b86ef1b5a; expires="Fri, 23-Jul-2027 08:55:28 GMT"; httponly; Max-Age=315360000; Path=/
  Set-cookie: sourceforge=bcda7ec9e4ed439a64c5e64e590620b984ed89bcgAJ9cQEoVQVwcmVmc3ECfXEDVQ5fYWNjZXNzZWRfdGltZXEER0HWXcHgBmPgVQNrZXlxBVUkMmI4NDc0ZGItZTNkNy00NzEwLThhM2QtOTc0Yjg2ZWYxYjVhcQZVDl9jcmVhdGlvbl90aW1lcQdHQdZdweAGY9xVA19pZHEIVSA0MzRjODBmYjk0NjM0ZGNmYjU4Y2JhYWIxODdkMjVkN3EJdS4=; expires=Tue, 19-Jan-2038 03:14:07 GMT; httponly; Path=/; secure
  Location: https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download
  X-Content-Type-Options: nosniff
  Strict-Transport-Security: max-age=31536000
Location: https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download [following]
--2017-07-25 10:55:28--  https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download
Connecting to sourceforge.net|216.34.181.60|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: nginx
  Date: Tue, 25 Jul 2017 08:55:28 GMT
  Content-Type: text/html; charset=utf-8
  Content-Length: 128476
  Connection: close
  Pragma: no-cache
  Cache-Control: no-cache
  X-UA-Compatible: IE=edge,chrome=1
  X-Frame-Options: SAMEORIGIN
  Content-Security-Policy: upgrade-insecure-requests
  Set-Cookie: VISITOR=2b8474db-e3d7-4710-8a3d-974b86ef1b5a; expires="Fri, 23-Jul-2027 08:55:28 GMT"; httponly; Max-Age=315360000; Path=/
  Set-cookie: sourceforge=797e45184f27a13d79e45d16b390a5e0bc9ef06dgAJ9cQEoVQhfZXhwaXJlc3ECY2RhdGV0aW1lCmRhdGV0aW1lCnEDVQoH9gETAw4HAAAAhVJxBFUDX2lkcQVVIDQzNGM4MGZiOTQ2MzRkY2ZiNThjYmFhYjE4N2QyNWQ3cQZVBmRsaGlzdHEHXXEIfXEJKFUHcmVsZWFzZXEKfXELKFUEZGF0ZXEMaANVCgfhBQ0KNwAAAACFUnENVQpzZl9maWxlX2lkcQ5KtGSWAVUIZmlsZW5hbWVxD1gjAAAAL2ZyZWV0eXBlMi8yLjgvZnJlZXR5cGUtMi44LnRhci5iejJxEHVVB3Byb2plY3RxEX1xEihVCXNob3J0bmFtZXETWAgAAABmcmVldHlwZXEUVQVzZl9pZHEVTVUMVQRuYW1lcRZYFAAAAFRoZSBGcmVlVHlwZSBQcm9qZWN0cRd1dWFVA2tleXEYVSQyYjg0NzRkYi1lM2Q3LTQ3MTAtOGEzZC05NzRiODZlZjFiNWFxGVUKY3VycmVudF9vc3EaXXEbKFUFd2luMzJxHFUHV2luZG93c3EdZVUFcHJlZnNxHn1xH1UOX2FjY2Vzc2VkX3RpbWVxIEdB1l3B4C2D8VUOX2NyZWF0aW9uX3RpbWVxIUdB1l3B4AZj3HUu; expires=Tue, 19-Jan-2038 03:14:07 GMT; httponly; Path=/; secure
  X-Content-Type-Options: nosniff
  Strict-Transport-Security: max-age=31536000
Length: 128476 (125K) [text/html]
Last-modified header missing -- time-stamps turned off.
--2017-07-25 10:55:28--  https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download
Connecting to sourceforge.net|216.34.181.60|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: nginx
  Date: Tue, 25 Jul 2017 08:55:29 GMT
  Content-Type: text/html; charset=utf-8
  Content-Length: 143733
  Connection: close
  Pragma: no-cache
  Cache-Control: no-cache
  X-UA-Compatible: IE=edge,chrome=1
  X-Frame-Options: SAMEORIGIN
  Content-Security-Policy: upgrade-insecure-requests
  Set-Cookie: VISITOR=2b8474db-e3d7-4710-8a3d-974b86ef1b5a; expires="Fri, 23-Jul-2027 08:55:29 GMT"; httponly; Max-Age=315360000; Path=/
  Set-cookie: sourceforge=b5bd929d9431625f7b220b04e97d1949367d4ed4gAJ9cQEoVQhfZXhwaXJlc3ECY2RhdGV0aW1lCmRhdGV0aW1lCnEDVQoH9gETAw4HAAAAhVJxBFUDX2lkcQVVIDQzNGM4MGZiOTQ2MzRkY2ZiNThjYmFhYjE4N2QyNWQ3cQZVBmRsaGlzdHEHXXEIfXEJKFUHcmVsZWFzZX1xCihVBGRhdGVoA1UKB+EFDQo3AAAAAIVScQtVCnNmX2ZpbGVfaWRKtGSWAVUIZmlsZW5hbWVYIwAAAC9mcmVldHlwZTIvMi44L2ZyZWV0eXBlLTIuOC50YXIuYnoydVUHcHJvamVjdH1xDChVCXNob3J0bmFtZVgIAAAAZnJlZXR5cGVVBXNmX2lkTVUMVQRuYW1lWBQAAABUaGUgRnJlZVR5cGUgUHJvamVjdHV1YVUDa2V5cQ1VJDJiODQ3NGRiLWUzZDctNDcxMC04YTNkLTk3NGI4NmVmMWI1YXEOVQpjdXJyZW50X29zcQ9dcRAoVQV3aW4zMnERVQdXaW5kb3dzcRJlVQVwcmVmc3ETfXEUVQ5fYWNjZXNzZWRfdGltZXEVR0HWXcHgU/ahVQ5fY3JlYXRpb25fdGltZXEWR0HWXcHgBmPcdS4=; expires=Tue, 19-Jan-2038 03:14:07 GMT; httponly; Path=/; secure
  X-Content-Type-Options: nosniff
  Strict-Transport-Security: max-age=31536000
Length: 143733 (140K) [text/html]
Saving to: ‘download.html’

download.html                                     100%[============================================================================================================>] 140.36K   338KB/s    in 0.4s

2017-07-25 10:55:29 (338 KB/s) - ‘download.html’ saved [143733/143733]
Brawny answered 1/11, 2016 at 10:23 Comment(0)
C
10

You could use wget only if you are fine that you will use an experimental functionality, which is the required "--content-disposition" option.

wget --content-disposition -c  https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2

All redirections are handled automagically, see the output below.

--2017-07-22 22:26:05--  https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2
Resolving sourceforge.net... 216.34.181.60
Connecting to sourceforge.net|216.34.181.60|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download [following]
--2017-07-22 22:26:06-- https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2/download
Connecting to sourceforge.net|216.34.181.60|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://downloads.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2?r=&ts=1500755167&use_mirror=kent [following]
--2017-07-22 22:26:07--  https://downloads.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2?r=&ts=1500755167&use_mirror=kent
Resolving downloads.sourceforge.net... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://kent.dl.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2 [following]
--2017-07-22 22:26:08--  https://kent.dl.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2
Resolving kent.dl.sourceforge.net... 212.219.56.185
Connecting to kent.dl.sourceforge.net|212.219.56.185|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1873526 (1.8M) [application/octet-stream]
--2017-07-22 22:26:08--  https://kent.dl.sourceforge.net/project/freetype/freetype2/2.8/freetype-2.8.tar.bz2
Connecting to kent.dl.sourceforge.net|212.219.56.185|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1873526 (1.8M) [application/octet-stream]
Saving to: ‘freetype-2.8.tar.bz2’

freetype-2.8.tar.bz2                              100%[==========================================================================================================>]   1.79M  5.60MB/s    in 0.3s

2017-07-22 22:26:08 (5.60 MB/s) - ‘freetype-2.8.tar.bz2’ saved [1873526/1873526]

Update to provide more details

➜  ~ ls -ld $(which wget)
lrwxr-xr-x  1 duda  admin  32  4 črv 19:44 /usr/local/bin/wget -> ../Cellar/wget/1.19.1_1/bin/wget
➜  ~ wget --version
GNU Wget 1.19.1 built on darwin16.6.0.

-cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls
+ntlm +opie -psl +ssl/openssl

Wgetrc:
    /usr/local/etc/wgetrc (system)
Compile:
    clang -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc"
    -DLOCALEDIR="/usr/local/Cellar/wget/1.19.1_1/share/locale" -I.
    -I../lib -I../lib -I/usr/local/opt/[email protected]/include -DNDEBUG
Link:
    clang -DNDEBUG -liconv -L/usr/local/opt/[email protected]/lib -lssl
    -lcrypto -ldl -lz ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a

Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic <[email protected]>.
Please send bug reports and questions to <[email protected]>.
Charles answered 22/7, 2017 at 20:35 Comment(6)
Executing this command in OSX, I get a file ‘download.html’ (which is a html file), instead of bz2 file. my wget command does not complain about the --content-disposition parameter, so i guess that it accepts it. any idea of why it is not working on my computer?Brawny
It works on my MacOS. I use the wget from the homebrew. ➜ ~ wget --help GNU Wget 1.19.1, a non-interactive network retriever.Charles
i am using wget 1.19.1 from homebrew also. it's so strange... i've posted my log in my question.Brawny
I also added the more detailed information. The only difference I see is your personal .wgetrc file.Charles
you are right! i was using this conf, which disguises the user_agent. github.com/donnemartin/dev-setup/blob/master/.wgetrc it works by removing that option, thx!Brawny
--content-disposition, that was the money shot right thereGenuine
G
2

try this:

wget -O [filename] [link to the downloadable file]

example:

wget -O TransLiG_1.3.tar.gz https://sourceforge.net/projects/transcriptomeassembly/files/TransLiG/TransLiG_1.3.tar.gz/download
Goggin answered 31/7, 2020 at 14:26 Comment(0)
B
0

Easiest method is to start the download on your browser, go to the browsers Download manager once the downloads starts in browser, and copy the url there - then use that direct url in wget.

Bit of a roundabout method - but works.

Backset answered 2/2, 2022 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.