26

Usually one would download a file with a URL ending in the file extension.

To download Ubuntu ISO, one would simple

wget http://releases.ubuntu.com/14.04.3/ubuntu-14.04.3-desktop-amd64.iso

However, I came accross a site that I suspect uses ASP.Net / IIS.

A link to a ISO is in this form (I removed link contents incase of ... policies):

http://some.ip.in.here/website.com/IMAGENAME.ISO?md5=hUhpyFjk7zEskw06ZhrWAQ&expires=1454811899

I am not sure how to download this since it has the MD5 and expiry time as parameters, and so wget only downloads a web page, not this ISO.

Any suggestions?

4
  • In such situations I recommend cliget addon for fx Jan 29, 2016 at 19:13
  • 2
    Are you putting your asp.net url in quotes (")? There is "&" character which will have side effect of running it in background and your server will not get full url.
    – user871199
    Jan 29, 2016 at 22:47
  • @user871199 Could you post this as an answer, this helped me
    – CybeX
    Jan 29, 2016 at 23:56
  • Unfortunately, if cookies are involved, it gets a lot harder. If correctly implemented by the web server, it’s even impossible without having a browser open on the same machine.
    – Daniel B
    Jan 30, 2016 at 13:08

3 Answers 3

27

Use

wget "http://some.ip.in.here/website.com/IMAGENAME.ISO?md5=hUhpyFjk7zEskw06ZhrWAQ&expires=1454811899"

Explanation: There is "&" character in the URL. On Linux and alike systems, this makes it a background process.

The solution is to enclose url in double quotes (") so that it’s treated as one argument.

5

If you are just trying to get a reasonable filename the complex URL, you can use the output-document option.

-O file
--output-document=file

Either of these forms will work.

As noted previously, be sure none of the special characters in the URL are getting interpreted by the command parser.

4

There are two ways you can do this using Curl.

In this first method you would the -O flag to write out the file based on the remote name from the URL; in this case it would most likely write the file out to the system as IMAGENAME.ISO?md5=hUhpyFjk7zEskw06ZhrWAQ&expires=1454811899; note how the URL value is contained by double quotes since & and ? might be misinterpreted as Bash commands:

curl -O -L "http://some.ip.in.here/website.com/IMAGENAME.ISO?md5=hUhpyFjk7zEskw06ZhrWAQ&expires=1454811899";

While that method technically “works” but the filename is confusing at best. So in this other method you would use output redirection—with > followed by a filename after the URL—to output the file contents to a file named IMAGENAME.ISO:

curl -L "http://some.ip.in.here/website.com/IMAGENAME.ISO?md5=hUhpyFjk7zEskw06ZhrWAQ&expires=1454811899" > "IMAGENAME.ISO";

So if you ask me, the second method works best for most average use. Also notice the -L flag being used in both commands; that commands tells Curl to follow any redirection links that a file download URL might have since a lot of times files on download services redirect a few times before landing at the destination payload file.

You must log in to answer this question.

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