我有一個wget
命令:
wget -r --no-parent -nH -nd -q --show-progress --progress=bar:force ftp://ftp.ncdc.noaa.gov/pub/data/swdi/database-csv/v2/
但它僅適用於較新版本的wget
.不幸的是我有一個舊版本wget
(GNU Wget 1.15 構建於 darwin14.3.0)並且無法升級它。具體來說,這是wget
--show-progress
不被識別的選項。
我想知道是否有等效的命令curl
?curl
我的系統上的版本是7.37.1(x86_64-apple-darwin14.0)。
答案1
但它僅適用於較新版本的
wget
.不幸的是我有一個舊版本wget
(GNU Wget 1.15 構建於 darwin14.3.0)並且無法升級它。具體來說,這是wget
--show-progress
不被識別的選項。
根據我對如何curl
工作和如何wget
工作的了解,它們可能表面上看起來相同,但wget
在curl
.要執行類似的操作,curl
需要一些奇特的 Bash 腳本來封裝該curl
指令。
那麼,當您說無法升級時wget
,到底是什麼意思呢?由於wget
它是一個 GNU 工具,因此它不隨 Darwin(基於 BSD)一起安裝,並且通常從原始程式碼編譯。事實上,您提供的版本詳細資訊顯然是透過某種方式從原始程式碼編譯的,因為該版本是「GNU Wget 1.15built on darwin14.3.0」。因此,如果該版本wget
是由類似的東西安裝的自製,這是有希望的,因為如果您的系統上有 Homebrew,那麼您的系統上也應該安裝 Xcode 以及相關的命令列工具/編譯器。
現在知道了這一點,您應該能夠wget
從原始程式碼編譯更新版本,例如 1.16.3;繞過 Homebrew 安裝版本並僅從您的主目錄執行它。您沒有root
/sudo
有權執行此操作;您可以按照以下方法進行操作。
從原始碼編譯wget
。
首先從官方來源網站取得壓縮檔案wget
:
curl -O http://ftp.gnu.org/gnu/wget/wget-1.16.3.tar.gz
接下來,像這樣解壓縮存檔:
tar -xzf wget-1.*.tar.gz
現在進入解壓縮後的目錄:
cd wget-1.*
運行這個configure
命令:
./configure --with-ssl=openssl
如果該configure
命令因某種原因失敗,您可能需要添加--with-libssl-prefix
以下值:
./configure --with-ssl=openssl --with-libssl-prefix=/usr/lib
過程完成後configure
,運行make
:
make
如果運行正常,則新編譯的 1.16.3 二進位版本wget
可供您使用。
wget
從您的主目錄執行新編譯的版本。
現在,大多數說明都會說您應該運行sudo make install
以wget
在系統上完全安裝。但是,如果您沒有root
/sudo
權限,或者您不想升級wget
系統範圍內安裝的版本,您仍然可以wget
像這樣執行剛剛編譯的二進位。首先,讓我們wget
像這樣退出來源目錄:
cd ~/
現在只需執行wget
剛剛明確編譯的 1.16.3 二進位檔案即可確認其正常運作:
~/wget-1.16.3/src/wget --version
輸出應該是這樣的:
GNU Wget 1.16.3 built on darwin13.4.0.
+digest +https +ipv6 -iri +large-file -nls +ntlm +opie -psl +ssl/openssl
Wgetrc:
/usr/local/etc/wgetrc (system)
Compile:
gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc"
-DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib
-DNDEBUG
Link:
gcc -DNDEBUG -liconv -lssl -lcrypto -ldl -lz ftp-opie.o openssl.o
http-ntlm.o ../lib/libgnu.a
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Originally written by Hrvoje Niksic <[email protected]>.
Please send bug reports and questions to <[email protected]>.
這意味著您現在開始做生意了!
wget
從主目錄運行命令。
因此,您現在可以運行wget
問題中發布的命令,如下所示:
~/wget-1.16.3/src/wget -r --no-parent -nH -nd -q --show-progress --progress=bar:force ftp://ftp.ncdc.noaa.gov/pub/data/swdi/database-csv/v2/
還有一個小調整(但值得注意的是),許多wget
選項都有全名和縮寫。所以--no-parent
可以縮短為-np
讓指令看起來像這樣:
~/wget-1.16.3/src/wget -r -np -nH -nd -q --show-progress --progress=bar:force ftp://ftp.ncdc.noaa.gov/pub/data/swdi/database-csv/v2/
使用後清理。
如果您想刪除wget
剛剛編譯的 1.16.3 內容(因為您說您正在使用的計算機不是您的),那麼只需刪除wget
您剛剛使用的源文件,如下所示:
rm wget-1.16.3.tar.gz
rm -rf wget-1.16.3