Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to use wget to automatically download a wallpaper. Here is the command:

wget http://static.die.net/earth/mercator/1600.jpg

However, if I try to open the resulting picture, it seems to say it has a bad magic number. By running file 1600.jpg, I get 1600.jpg: GIF image data, version 89a, 1 x 1. If I open it as a GIF it doesn't work either. It's only 37 bytes too.

It works perfectly fine if I view or download it through Firefox.

Any ideas?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

I think it's some kind of protection against direct downloads, nothing wrong with wget (the server is sending you a transparent 1x1 GIF image).

You can circumvent this by using wget with the -U flag, adding the user agent string of your browser, eg.:

wget -U "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.17 (KHTML, like Gecko) Ubuntu/11.04 Chromium/11.0.654.0 Chrome/11.0.654.0 Safari/534.17" http://static.die.net/earth/mercator/1600.jpg

BUT: You should first ask the owner of that website if it's ok to download the content this way. There has to be a reason why the usual wget approach is blocked (maybe it's intentional, maybe it's just misconfiguration).

share|improve this answer
2  
I see. But why isn't Firefox affected? And how would I get around that? –  alecRN Feb 5 '11 at 17:10
1  
@alecRN: See update. –  htorque Feb 5 '11 at 17:25
    
Thank you! It works perfectly now! –  alecRN Feb 5 '11 at 17:33
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.