修改ubuntu下的hosts 你懂的

#!/usr/bin/ruby
#coding=utf-8
require 'open-uri'

url= "http ://raw.github usercontent.com/ vokins/simpleu/master/hosts"

begin
  open("/etc/hosts","w") do |x|
    x.write open(url).read
  end
rescue Errno::EACCES
  puts "Need root? "
  exec "sudo ruby " + $0 + ARGV.join(' ')
end
puts "Write hosts success!"

编程技巧