shijiang1130 发表于 2013-04-20 21:53

介绍个color模块给你

本帖最后由 shijiang1130 于 2013-04-20 21:54 编辑


require 'rubygems'                     
require 'colorize'                     
                                       
   def ping_o                              
         ips=(1..253)                     
         threads=[]                     
         ips.each { |ip|                  
                   threads << Thread.new do
                           host = '192.168.0.' + ip.to_s                                                
                        Thread.current["result"]=`ping -c 1 -w 1 192.168.0.#{ip}`
                        Thread.current["ip"]    = host
                        end            
          }                              
                                          
          threads.each { |t|               
          t.join                           
          puts t["ip"].colorize(:red)      
          puts t["result"].colorize(:yellow)
          }                              
end                                    
                                          
while(1)                                 
ping_o                                 
sleep 1                                 
end                                    
                        

水月蓝魔 发表于 2013-04-20 22:59

新人,学习下。。
页: [1]
查看完整版本: 介绍个color模块给你