我在bash小片段bash腳本爆發循環不發送郵件
retries = 3
for ((i=0; i<retries; i++)); do
curl -1 --cipher ALL --connect-timeout 90 -T $zip_name ftps://ftp.box.com/Backup/$zip_name --user [email protected]:§fHyFSDF$o6
[[ $? -eq 0 ]] && break
echo "something went wrong, let's wait 6 seconds and retry"
sleep 6
done
[[ $retries -eq i ]] && { echo "This email is a notification of Failure" | mail -s "Failed" "[email protected]" ; exit 1; }
上述循環應重試3次,如果有做捲曲一個錯誤,所以如果捲曲錯誤出現這應該郵寄到電子郵件。但是,爲了測試它我撤銷用戶的訪問,所以我期望的電子郵件,但是這並沒有工作,我收到以下控制檯上:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
curl: (9) Server denied you to change to the given directory
爲什麼代碼,如果訪問,如果打破了第一次嘗試撤銷上傳服務器
https://www.gnu.org/software/bash/manual/html_node/Quoting.html#Quoting – hek2mgl
@ hek2mgl你可以詳細說明你想說的話? – Kittystone
我說你需要引用(a)變量和(b)包含特殊字符的字符串。我在代碼中看不到引號。 – hek2mgl