介绍个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
新人,学习下。。
页:
[1]