
curl --max-time 3 'http://website.com';
if [ 0 -eq $? ]; then
...
else
...
fi
我試圖讓curl 對超時的URL 做出不同的回應。如何將curl失敗的輸出傳遞到if語句中?這根本行不通:
答案1
curl
退出代碼( 的值$?
)記錄在其線上說明頁面中。退出代碼 28 對應於“操作超時。依條件已達到規定的超時期限。」
curl --max-time 3 'http://website.com';
if [ 0 -eq $? ]; then
...
else
...
fi
我試圖讓curl 對超時的URL 做出不同的回應。如何將curl失敗的輸出傳遞到if語句中?這根本行不通:
curl
退出代碼( 的值$?
)記錄在其線上說明頁面中。退出代碼 28 對應於“操作超時。依條件已達到規定的超時期限。」