要从服务器下载SOFA统计信息,我使用wget命令:
wget -c http://sourceforge.net/projects/sofastatistics/files/latest/download?source=dlp
在这种情况下,下载文件的文件名是下载?源代码文件。如果我在命令中添加了
--outport-文档
选项,将输出文件重命名为sofastatistics-latest.deb
,下载文件的格式将无法被dpkg包识别。
dpkg-deb: error: `sofastatistics-latest.deb' is not a debian format archive
如何正确重命名下载文件与wget?
更新-2015年1月8日
通过提供的链接,下载的文件始终为*。焦油gz一号。要获得实名,只需添加--content disposition
选项如下(感谢@6eqj5!):
wget --content-disposition http://sourceforge.net/projects/sofastatistics/files/latest/download?source=dlp
但我需要一个*。deb文件,所以这里是正确的@creakative,我必须搜索一个*。deb文件链接。
谢谢大家的回答!
将标准输出重定向到任意文件名始终有效。你做的是正确的,正如人们所说,使用-O
wget http://www.kernel.org/pub/linux/kernel/README -O foo
--2013-01-13 18:59:44-- http://www.kernel.org/pub/linux/kernel/README
Resolving www.kernel.org... 149.20.4.69, 149.20.20.133
Connecting to www.kernel.org|149.20.4.69|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12056 (12K) [text/plain]
Saving to: `foo'
100%[======================================================================================================================================>] 12,056 --.-K/s in 0.003s
2013-01-13 18:59:45 (4.39 MB/s) - `foo' saved [12056/12056]
事实上,您的文件中必须包含HTML(通常可以使用man文件进行检查)。
[编辑]
在您的示例中,客户端接收到302 find(您可以使用curl-vURL检查它)。
下面的卷曲通过3xx实现了这一点:
$ curl -L http://sourceforge.net/projects/sofastatistics/files/latest/download?source=files -o foo.deb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 463 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
100 2035k 100 2035k 0 0 390k 0 0:00:05 0:00:05 --:--:-- 1541k
$ file foo.deb
foo.deb: gzip compressed data, was "sofastats-1.3.1.tar", last modified: Thu Jan 10 00:30:44 2013, max compression
wget应该有类似的选项来容忍HTTP重定向。
如果要从web浏览器进行相同的下载,并且注意到浏览器实际上正确命名了文件,则可以使用--content disposition
选项为wget提供相同的行为:
wget --content-disposition http://sourceforge.net/projects/sofastatistics/files/latest/download?source=dlp
我的Debian手册页将此报告为“实验性”功能,但我想不起来它对我不起作用:
--content-disposition
If this is set to on, experimental (not fully-functional) support for "Content-Disposition" headers is enabled. This can currently result in extra round-trips to the server
for a "HEAD" request, and is known to suffer from a few bugs, which is why it is not currently enabled by default.
This option is useful for some file-downloading CGI programs that use "Content-Disposition" headers to describe what the name of a downloaded file should be.
这个链接指向重定向器,而不是最终目的地!所以您正在下载超文本标记语言并将其重命名为. deb
。凌乱的页面顶部有这样一个:
您的下载将在0秒后开始。。。下载有问题吗?请使用此直接链接,或尝试其他镜像。
现在,这是一个有效的链接(请注意download
前缀):http://downloads.sourceforge.net/project/sofastatistics/sofastatistics/1.3.1/sofastats-1.3.1-1_all.deb?r=http://sourceforge.net/projects/sofastatistics/files/sofastatistics/1.3.1/
将此URL传递到wget
。另外,请注意,SourceForge试图超越您,通过用户代理字符串访问操作系统。“wget”的最佳猜测似乎是。焦油gz包。因此,您应该更具体地请求deb文件!