#!/usr/bin/ruby
nic = "eth1"
aps = Hash.new
essid = nil
`sudo iwlist #{nic} scan`.each do |line|
if line =~ /ESSID:(.*)/
essid = $1
elsif line =~ /Encryption\skey:(.*)/
encryption = $1
essid = nil if encryption == 'on'
elsif line =~ /Quality=(\d+)\/100/
quality = $1.to_i
aps[essid] = quality if essid
end
end
best = ""
last = 0
aps.each_pair do |essid,quality|
best = essid if quality > last
end
system("sudo iwconfig #{nic} essid #{best}")
system("sudo dhclient #{nic}")
aw yes! this make my coputer get from best webbing site faster! do it frendly time!
No comments:
Post a Comment