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