Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

2 Answers 2

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

share|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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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