-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.txt
63 lines (54 loc) · 1.34 KB
/
count.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
https://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html
https://stackoverflow.com/questions/13638670/adding-counter-in-shell-script
https://www.tutorialspoint.com/unix/if-elif-statement.htm
https://alvinalexander.com/linux-unix/linux-shell-script-counter-math-addition-loop/
$ cat count.sh
counter=0
while true; do
if [ -f /home/script ]
then
echo "Files Present"
exit 0
elif [[ "$counter" -gt 5 ]]; then
echo "Counter: $counter times reached; Exiting loop!"
exit 1
else
counter=$((counter+1))
echo "Counter: $counter time(s); Sleeping for another half an hour"
sleep 3
fi
done
#
# a shell script loop/counter example
# alvin alexander, http://alvinalexander.com
#
count=1
while [ $count -lt 200 ]
do
filename="node${count}.shtml"
echo "Redirect 301 /java/java_oo/${filename} http://www.devdaily.com/java/java_oo/"
count=`expr $count + 1`
done
#!/bin/bash
urls="
https://www.baidu.com
https://www.taobao.com
https://www.jd.com/abc
https://www.12306.cn/index/
192.168.1.111
"
echo $urls
for url in $urls;do
count=0
while [ $count -lt 3 ];do
STATUS=$(curl -I -m 10 -o /dev/null -s -w %{http_code} $url)
if [ $STATUS -eq 200 ];then
echo "$url OK"
break 1
fi
count=$(($count+1))
done
if [ $count -eq 3 ];then
echo "$url Error"
fi
done