1
我試圖錯誤陷阱用戶輸入。錯誤陷阱用戶輸入 - Bash腳本循環
- 我需要用戶輸入文件名。
- 有些用戶正在輸入完整的URL,並殺死了腳本的其餘部分。
- 因此,如果用戶輸入http://我希望腳本給出一個錯誤消息,並讓他們只輸入文件名。
- 每次用戶輸入網址時都需要重複。
- 如果他們輸入文件名,則執行腳本的其餘部分。
這是我到目前爲止。如果用戶輸入的網址,一旦它的工作原理,但如果他錯了輸入兩次它將執行腳本
#!/bin/bash
read -p "Enter File : " string
if [[ $string -ne *」http://「* ]];
then
s3cmd get s3://backup/domain.com/$string
elif [[ $string -ne *"http://"* ]];
echo 「You entered the full URL, enter on the file name「
read -p "Enter File : " string
then
s3cmd get s3://backup/domain.com/$string
else
echo "rest of script"
fi