Curl
curl:在“-sS”上使用“–no-progress-meter”時?
即將
curl
隱藏進度表我通過Stack Exchange分支找到了很多答案,提到-s
和-S
或只是-sS
在哪裡
-s
隱藏進度表-S
僅顯示錯誤消息,即使-s
使用因此建議工作為
-sS
curl
在一些文章中提到了作為關於該選項的新增內容--no-progress-meter
,例如:我讀
man
--no-progress-meter Option to switch off the progress meter output without muting or otherwise affecting warning and informational messages like --silent does. Note that this is the negated option name documented. You can thus use --progress-meter to enable the progress meter again. Example: curl --no-progress-meter -o store https://example.com See also -v, --verbose and -s, --silent. Added in 7.67.0.
和curl ootw:–silent(由重要的 curl 送出者編寫)
但遺憾的是,我不清楚它是如何
--no-progress-meter
工作的。乍一看,我認為它--no-progress-meter
等同於-sS
但是 - 在兩種資源中都沒有明確指出 - 因此我的假設是不正確的。我確實做了一些實驗:
沒有錯誤
#1 curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O # Shows % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 8472k 100 8472k 0 0 3500k 0 0:00:02 0:00:02 --:--:-- 3501k #2 curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O -s # Shows Nothing #3 curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O -sS # Shows Nothing #4 curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O --no-progress-meter # Shows Nothing
實際上並不清楚和之間的區別
-sS
,--no-progress-meter
因為沒有錯誤。有錯誤
錯誤,因為
URL
不正確,它僅基於https
部分#1 curl https -O # Shows curl: Remote file name has no length! curl: (23) Failed writing received data to disk/application #2 curl https -O -s # Shows nothing #3 curl https -O -sS # Shows curl: (23) Failed writing received data to disk/application #4 curl https -O --no-progress-meter # Shows curl: Remote file name has no length! curl: (23) Failed writing received data to disk/application
觀察是一樣
#1
的#2
問題
- 什麼時候
-no-progress-meter
用完-sS
?如果你能分享一些真實的例子來理解差異,不勝感激。
手冊頁說:
-s, --silent Silent or quiet mode. Don't show progress meter or error mes‐ sages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it. Use -S, --show-error in addition to this option to disable progress meter but still show error messages.
所以本質上,有四種可能的組合,以增加安靜度的順序:
- 沒有選項:顯示進度表、警告消息和錯誤消息
- with
--no-progress-meter
:顯示警告消息和錯誤消息,但不顯示進度表。如果出現問題,此選項會提供資訊,但如果沒有問題,則不會顯示。- with
-sS
:僅顯示錯誤消息,但不顯示進度表或警告消息。如果您正在編寫腳本並且知道在特定情況下某些內容可能會導致無害的警告消息,但如果發生意外情況仍希望顯示錯誤消息,那就太好了。- with
-s
:完全保持沉默,完全沒有消息。