猜数字
vim num.sh
num=`expr $RANDOM % 100`
echo $num
kong=0
while :
do
read -p "请输入要比较的数字:" shu
echo $shu
let kong++
if [ $shu -gt $num ];then
echo "猜大了"
elif [ $shu -lt $num ];then
echo "猜小了"
else
echo "猜对了"
echo "共猜了$kong次"
break
fi
done
域名监控
vim ip.sh
check_website(){
web=($(cat yuming))
for i in ${web[@]}
do
code=$(curl -I -m 1 -o /dev/null -s -w %{http_code} $i)
if [ $code -eq 200 ]; then
echo "$i is ok"
else
echo "$i is ok,please check!!"
echo "$i is not ok,pleasecheck!!"| mail -s "url check" qiyuezhi1121@163.com
fi
done
}
while :
do
check_website
sleep 2
done