我正在尝试使用 wget 下载 Raspberry Pi 的 Raspbian 映像(http://downloads.raspberrypi.org/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian)。压缩)。
它开始下载正常,但在一秒钟后完成,没有错误,但显然没有完成,并留下一个小文件而不是完整的文件:
kemra102@iacon:~/Downloads$ wget http://downloads.raspberrypi.org/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip
--2012-08-13 20:26:57-- http://downloads.raspberrypi.org/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip
Resolving downloads.raspberrypi.org (downloads.raspberrypi.org)... 94.136.44.110
Connecting to downloads.raspberrypi.org (downloads.raspberrypi.org)|94.136.44.110|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://downloads.raspberrypi.org/download.php?file=/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip [following]
--2012-08-13 20:26:57-- http://downloads.raspberrypi.org/download.php?file=/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip
Reusing existing connection to downloads.raspberrypi.org:80.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `2012-07-15-wheezy-raspbian.zip'
[ <=> ] 17,012 --.-K/s in 0.04s
2012-08-13 20:26:57 (373 KB/s) - `2012-07-15-wheezy-raspbian.zip' saved [17012]
kemra102@iacon:~/Downloads$ ls -l 2012-07-15-wheezy-raspbian.zip
-rw-rw-r-- 1 kemra102 kemra102 17012 Aug 13 20:26 2012-07-15-wheezy-raspbian.zip
kemra102@iacon:~/Downloads$
我无法在网络上的任何地方找到任何内容来表明可能导致该问题的原因。
答案1
尝试查看您收到的文件:
$ wget http://downloads.raspberrypi.org/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip
-- snip --
2012-08-13 16:31:23 (9.78 MB/s) - `2012-07-15-wheezy-raspbian.zip' saved [6501]
$ file 2012-07-15-wheezy-raspbian.zip
2012-07-15-wheezy-raspbian.zip: HTML document text
我们可以看到我们实际上收到了一个 HTML 文档。输出中的行进一步证明了这一点:Length: unspecified [text/html]
另请注意,当您调用 wget 时,服务器会立即重定向到http://downloads.raspberrypi.org/download.php?file=/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip
确实是一个网页。
尝试在浏览器中打开以下任一链接:
- http://downloads.raspberrypi.org/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip
- http://downloads.raspberrypi.org/download.php?file=/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip
当您这样做时,您会看到一个下载信息页面。该页面上有一个直接下载链接。经过那链接到 wget 就可以了。
答案2
您的 wget 正在被重定向(HTTP 状态 301):使用直接链接反而。