This doc is adapted from this blog post. The main update from the blog post is the additional information for getting the download to get the correct filename and the additional information about specifying a mirror. The rest is pretty much the same.
Command line gurus out there are likely familiar with the tools wget and curl, both useful for requesting URLs from the command line. What may be less clear is how to use curl and wget to download files from SourceForge. Strap in and hang on because you’re about to become a download ninja.
We’re going to use wget but the same principles also apply to curl; just be sure to add the -L option to follow the redirect to our mirrors and the -o option to specify the file name. A typical wget command looks like this:
$ wget -O myfile.zip http://example.com/myfile.zip
Pretty simple, eh?
All a download ninja needs is the URL of the SourceForge download. Here’s where we separate the senpai from the kōhai: download ninjas know the same URL can be used with wget. For example, our ninja needs to download phpPgAdmin, a web-based administration tool for PostgreSQL databases. The ninja clicks on phpPgAdmin’s GDB (Green Download Button) and ends up at the following URL:
Reacting with deadly grace, the ninja copies and pastes that URL into the command line (>> indicates line wrap):
$ wget -O phpPgAdmin-5.0.2.tar.gz >> http://sourceforge.net/projects/phppgadmin/files/>> phpPgAdmin%20%5Bstable%5D/phpPgAdmin-5.0/>> phpPgAdmin-5.0.2.tar.gz/download ... Saving to: "phpPgAdmin-5.0.2.tar.gz" 100%[============================================================>] 1,063,554 694K/s in 1.5s 2011-02-18 00:17:40 (694 KB/s) - “phpPgAdmin-5.0.2.tar.gz” saved [1063554/1063554]
Masterfully slicing through the interwebs, the download ninja stealthily slips away with an awesome PostgreSQL tool. Pretty sweet, huh?
The goodness isn’t limited to just curl and wget: download/install tools like Python’s easy_install or an application’s auto-update utility can also use these URLs.
We also have a special “latest/download” URL that’s a bit like Google’s “I’m Feeling Lucky” button for downloads:
$ wget >> http://sourceforge.net/projects/phppgadmin/files/latest/download
If you use it we’ll try to send you the latest download. Wget (and similar tools) makes it a little tricky to figure out if you’re on Windows, a Mac, Linux, etc. If you’re downloading something that’s OS-specific you’re better off using the full URL.
Some builds of Wget aren’t quite as ninjariffic about figuring out the right filename for saving locally (it might just save with the filename "download"). If your wget build doesn't get the right filename by default, you essentially have three options:
.wgetrcfile, you won't need to specify this each time you run wget.
It's also possible to specify a download mirror by using the
use_mirror option like so:
$ wget -O phpPgAdmin-5.0.2.tar.gz >> http://sourceforge.net/projects/phppgadmin/files/>> phpPgAdmin%20%5Bstable%5D/phpPgAdmin-5.0/>> phpPgAdmin-5.0.2.tar.gz/download?use_mirror=voxel ... Connecting to voxel.dl.sourceforge.net|184.108.40.206|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1063554 (1.0M) [application/x-gzip] Saving to: `phpPgAdmin-5.0.2.tar.gz' 100%[==============================================================================>] 1,063,554 818K/s in 1.3s 2011-09-26 16:43:47 (818 KB/s) - `phpPgAdmin-5.0.2.tar.gz' saved [1063554/1063554]
In the example, I downloaded from the 'voxel' mirror, but you can replace that with any other mirror shortname as listed here.
Note that it's not guaranteed that all files will be on every mirror, if the file isn't available on the chosen mirror, then it'll just auto-select a different one.