Let's a consider link such as htttp://www.mysite.net/download.php?id=267 that redirects to htttp://www.mysite.net/downloads/myfile.tar.gz

If I execute 'wget "htttp://www.mysite.net/download.php?id=267"' wget will happily download and save the result in a file named "download.php?id=333". Naming this file "myfile.tar.gz" would have made much more sense.

There is of course the workaround of using 'wget -O myfile.tar.gz "htttp://www.mysite.net/download.php?id=267"' but this is not what I want : I want wget to do the right thing automatically.

Is there any anyway to tell wget to use the name of the target file behind the HTTP redirect ?

I there any other similar tool that would do that ?

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted
wget --trust-server-names=on htttp://www.mysite.net/download.php?id=267

Or option trust-server-names in ~/.wgetrc.

It may be a security risk if the HTTP redirect goes to ../../../../../../../../../../../../etc/passwd

link|improve this answer
Now I realize that trusting server names was the former default... And I now understand your reference to CVE-2010-2252 on Twitter ! – Jean-Marc Liotier Sep 24 '10 at 15:50
feedback

I found that lynx will often get the file behind the redirect too.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.