shell脚本exercise2

纵然是瞬间 提交于 2019-12-23 17:51:20

通过文件里面的网址,判断是否访问成功网址

 1 #!/bin/bash
 2 check(){
 3         code=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://$url`
 4         echo $code
 5         if [ $code -eq 200 ]; then
 6                 echo "ok"
 7         else
 8                 echo "not ok"
 9         fi
10 }
11 :<<EOF
12 while read url
13 do
14         check
15 done < url.txt
16 EOF
17 for url in `cat url.txt`
18 do
19         check
20 done

防止DDoS攻击

 1 #!/bin/bash
 2 webdir=/var/www/html/
 3 ##校验文件内容
 4 md5sum -c --quiet /opt/webfile.db
 5 if [ $? -eq 0 ]; then
 6         echo "web dir is safely"
 7 else
 8         echo "web dir is risk"
 9 fi
10 find $webdir -type f > /opt/countfile_change
11 count=$(diff /opt/countfile*|wc -l)
12 if [ $count -gt 0 ]; then
13         echo "web 被篡改!"
14 else
15         echo "ok"
16 fi

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!