93

サーバーから SOFA 統計をダウンロードするには、wget コマンドを使用します。

wget -c http://sourceforge.net/projects/sofastatistics/files/latest/download?source=dlp

この場合のダウンロードファイルのファイル名はdownload?source=files. --output-document出力ファイルの名前を に変更するオプションをコマンドに追加するsofastatistics-latest.debと、ダウンロードしたファイルの形式が dpkg パッケージで認識されません。

dpkg-deb: error: `sofastatistics-latest.deb' is not a debian format archive

wgetでダウンロードしたファイルの名前を正しく変更するには?

更新 - 2015 年1 月 8 日

提供されたリンクを使用すると、ダウンロードされるファイルは常に *.tar.gz になります。実際の名前で取得するには、次のように--content-dispositionオプションを追加するだけです (@6EQUJ5 に感謝!):

wget --content-disposition http://sourceforge.net/projects/sofastatistics/files/latest/download?source=dlp

しかし、*.deb ファイルが必要だったので、ここに @creaktive があり、*.deb ファイル リンクを検索する必要がありました。

答えてくれてありがとう!

4

4 に答える 4

120

標準出力の任意のファイル名へのリダイレクトは常に機能します。man wgetが言うように、-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 Foundを受信して​​います( curl -v URLで確認できます)。

次のカールは、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リダイレクトを許容するための同様のオプションがあるはずです。

于 2013-01-13T18:01:40.333 に答える
24

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.
于 2015-01-07T09:36:00.053 に答える
1

そのリンクは、最終的な宛先ではなく、リダイレクタを指しています。つまり、HTMLをダウンロードして、名前をに変更し.debます。雑然としたページの上部には次のようなものがあります。

ダウンロードは0秒で開始されます...ダウンロードに問題がありますか?この直接リンクを使用するか、別のミラーを試してください。

現在、これは有効なリンクです(downloadプレフィックスに注意してください): http ://downloads.sourceforge.net/project/sofastatistics/sofastatistics/1.3.1/sofastats-1.3.1-1_all.deb?r = http%3A%2F %2Fsourceforge.net%2Fprojects%2Fsofastatistics%2Ffiles%2Fsofastatistics%2F1.3.1%2F&ts = 1358119361&use_mirror = ufpr

このURLをに渡しますwget。また、SourceForgeは、User-Agent文字列を介して運用システムをゲストとして使用し、ユーザーを裏切ろうとしていることに注意してください。「wget」の最良の推測は.tar.gzパッケージのようです。したがって、debファイルを要求して、より具体的にする必要があります。

于 2013-01-13T18:01:22.040 に答える