[Techtalk] download_script.php with wget

Mary mary-linuxchix at puzzling.org
Tue Jan 11 10:44:45 EST 2005


On Mon, Jan 10, 2005, Gretchen Dziengel wrote:
> When I have some down time at work, I log in to my home computer to play
> around with Linux stuff.  Lots of times I like to download files to my
> home computer with wget.  Works great most of the time.  I copy the link
> right into putty.  The problem is with urls such as:
> http://www.vim.org/scripts/download_script.php?src_id=3576
> 
> That downloads a file called "download_script.php?src_id3576"  That file
> is not the file I've tried to download either.

The file I download via:

    wget http://www.vim.org/scripts/download_script.php?src_id=3576

is exactly the same as the file I get by visiting that URL with Mozilla
and saving the file. They just have different names (and different
permissions thanks to downloading them with different programs):

    $ ls -l Viki.zip download_script.php\?src_id\=3576
    -rw-rw-r--    1 mary     mary        30939 Jan 11 10:33 download_script.php?src_id=3576
    -rw-------    1 mary     mary        30939 Jan 11 10:34 Viki.zip

"download_script.php?src_id=3576" is the wget file, "Viki.zip" the
Mozilla file. I can even unzip the one with the stupid name:

    $ unzip download_script.php\?src_id\=3576
    Archive:  download_script.php?src_id=3576
       creating: Viki/
       creating: Viki/compiler/
      inflating: Viki/compiler/deplate.vim
       creating: Viki/doc/
      inflating: Viki/doc/viki.txt
       creating: Viki/etc/
      inflating: Viki/etc/Viki.lst
       creating: Viki/ftplugin/
       creating: Viki/ftplugin/bib/
      inflating: Viki/ftplugin/bib/viki.vim
      inflating: Viki/ftplugin/viki.vim
       creating: Viki/indent/
      inflating: Viki/indent/viki.vim
       creating: Viki/plugin/
      inflating: Viki/plugin/viki.vim
      inflating: Viki/plugin/vikiLatex.vim
       creating: Viki/syntax/
      inflating: Viki/syntax/viki.vim

So I'm not sure what you mean by "That file is not the file I've tried
to download either." Mozilla and wget get exactly the same file for me.
What's in the wgetted file for you? Is it binary? Is it unzippable?

Assumign that you get the same behaviour as me (ie a binary file that
seems to be the right data but with the wrong name) it's meant to be the
case that scripts like this download_script.php set an HTTP header
saying "the name of the file to be downloaded is not
download_script.php, but Viki.zip". Either this header is not being set
correctly by www.vim.org or wget is misunderstanding it. It's not
official, so some clients do ignore it.

In order to help with your Googling, the header in question is the
"Content-disposition" header.

If you get the same behaviour as me, you could try giving the -O flag to
wget to specify the output file, or just rename wget's file to something
with a more sensible name. If it's really the case that
download_script.php?src_id=3576 has the wrong stuff in it, it might be
useful to post, say, the first 10 lines of what's actually in that file
to help us debug what's going on.

-Mary


More information about the Techtalk mailing list