Method One:
1[[Email protected] script]#VI check_url_01.sh2 3 #!/bin/sh4 #This script was created by Nulige5 #Check URL Add6 #version1.17. /etc/init.d/functions8 9url_list=(Ten/HTTPwww.baidu.com One/HTTPwww.qq.com Ahttp://192.168.146.128 - ) - the function Wait () - { -Echo-n'after 3 seconds, perform the operation'; - for(i=0; i<3; i++)) + Do -Echo-n"."; Sleep 1 + Done A Echo at } - - function Check_url () { -Set-x - wait -Set +x inEcho'Check URL ...' - for(i=0; i<${#url_list[*]}; i++)) to Do + #http/1.1 OK -Judge= ($ (curl-i-S ${url_list[$i]}|head-1|tr"\ r" "\ n")) the if[["${judge[1]}"==' $'&&"${judge[2]}"=='OK' ]] * Then $Action"${url_list[$i]}"/bin/truePanax Notoginseng Else -Action"${url_list[$i]}"/bin/false the fi + Done A } theCheck_url
Execution Result:
1 [[email protected] script]#23 seconds later, do the operation; 3 Check URL ... 4 /www.baidu.com [OK]5 http/www.qq.com [OK]6 /http 192.168.1.7 [OK]
Check URL address script