ruby实现修改ubuntu下的hosts
在Windows下面,我们修改hosts文件都知道在哪里,但是在ubuntu系统中呢,还有其它的系统,比如安卓手机,或许就没那么多的小软件可供你简单的修改了,我们自己来写个吧
#!/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!"
以上所述就是本文的全部内容了,希望大家能喜欢
相关推荐
PMJ0 2020-10-13
longzhiwen 2020-09-06
yangxingstar 2020-08-31
LUCIEN0 2020-08-17
huangzihao00 2020-08-17
Jan 2020-08-17
AndesStay 2020-06-12
afengxg 2020-06-09
zamesking 2020-06-09
afengxg 2020-06-09
何志文 2020-06-09
teresalxm 2020-06-05
何志文 2020-05-16
何志文 2020-05-11
fsl 2020-05-04
JOO 2020-04-26
倩 2020-04-22
afanti 2020-04-19
始终不够 2020-04-10