wget save real file name

user-pic
Vote 0 Votes

wget 遇到有轉址時, save 的檔名可能會不正確
例如:
# wget http://hk1.php.net/get/php-5.6.11.tar.bz2/from/this/mirror
--2015-07-22 14:32:35-- http://hk1.php.net/get/php-5.6.11.tar.bz2/from/this/mirror
Resolving hk1.php.net... 202.67.138.74
Connecting to hk1.php.net|202.67.138.74|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://hk1.php.net/distributions/php-5.6.11.tar.bz2 [following]
--2015-07-22 14:32:35-- http://hk1.php.net/distributions/php-5.6.11.tar.bz2
Connecting to hk1.php.net|202.67.138.74|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14081292 (13M) [application/octet-stream]
Saving to: `mirror'

加 --content-disposition 就會讓 save 的檔名是正確的
# wget --content-disposition http://hk1.php.net/get/php-5.6.11.tar.bz2/from/this/mirror
--2015-07-22 14:56:25-- http://hk1.php.net/get/php-5.6.11.tar.bz2/from/this/mirror
Resolving hk1.php.net... 202.67.138.74
Connecting to hk1.php.net|202.67.138.74|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://hk1.php.net/distributions/php-5.6.11.tar.bz2 [following]
--2015-07-22 14:56:25-- http://hk1.php.net/distributions/php-5.6.11.tar.bz2
Connecting to hk1.php.net|202.67.138.74|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14081292 (13M) [application/octet-stream]
--2015-07-22 14:56:25-- http://hk1.php.net/distributions/php-5.6.11.tar.bz2
Reusing existing connection to hk1.php.net:80.
HTTP request sent, awaiting response... 200 OK
Length: 14081292 (13M) [application/octet-stream]
Saving to: `php-5.6.11.tar.bz2'

--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.

About this Entry

This page contains a single entry by Pank published on July 22, 2015 3:30 PM.

ImageMagick Appending Images with convert was the previous entry in this blog.

AnyDesk - Teamviewer Alternative is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives