欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ruby實(shí)現(xiàn)修改ubuntu下的hosts

 更新時(shí)間:2015年06月04日 09:47:43   投稿:hebedich  
本文給大家分享的是通過(guò)ruby獲取github上的hosts文件內(nèi)容,修改到本地Ubuntu中,十分的實(shí)用,具體你懂得,有需要的小伙伴可以參考下。

在Windows下面,我們修改hosts文件都知道在哪里,但是在ubuntu系統(tǒng)中呢,還有其它的系統(tǒng),比如安卓手機(jī),或許就沒(méi)那么多的小軟件可供你簡(jiǎn)單的修改了,我們自己來(lái)寫(xiě)個(gè)吧

#!/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!"

以上所述就是本文的全部?jī)?nèi)容了,希望大家能喜歡

相關(guān)文章

最新評(píng)論