转载:http://blog.csdn.net/longxibendi/article/details/6412822
#!/bin/bash #author longxibendi #blog http://blog.csdn.net/longxibendi #function get the web servers information of companies' if [ -e ./web_server.log ] ;then rm -f ./web_server.log fi if [ -e ./ab.log ] ; then rm -f ./ab.log fi for company_name in taobao jd dangdang vancl mbaobao alibaba baidu yahoo sina sohu renren changyou wanmei 126 163 139 do { ab -n 1 -c 1 http://www.${company_name}.com/index.html | tee ./ab_${company_name}.log 2>&1 if [ $? -eq 0 ] ; then printf "%15s, %20s\n" "${company_name}.com", " ` cat ./ab_${company_name}.log | grep "Server Software" ` " >> ./web_server.log fi sleep 2 }& done wait echo "It is OK "