当前位置:编程学习 > C/C++ >>

自动化ping

查看是否ping通网站

[cpp] 
#!/bin/bash 
#Checks to see if hosts 192.168.1.100-192.168.1.200 are alive 
for n in {100..200}; do 
         host=192.168.1.$n 
         ping -c 2 $host >/dev/null 
         if [ $? = 0 ]; then                      
            echo "$host is UP"          
         else 
            echo "$host is DOWN"          
         fi 
done  

读网站文本

[cpp] 
#!/bin/bash 
while read host 
do 
    ping -c 2 $host >/dev/null 
    if [ $? = 0 ] 
    then 
        echo "$host"          
    else  
        echo "$hostN" 
    fi 
done < domain.txt  


 

 

补充:软件开发 , C++ ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,