嗯嗯,啥也不说了。其实就是个从一些网站上获取最新Hosts。为了安全起见,需要以root权限运行。

貌似代码的缩进出现问题了。下载:http://forum.ubuntu.org.cn/download/file.php?id=167672

# coding=utf-8
import urllib
import os

def Download():
h=open('hosts','w')
fh=urllib.urlopen("https://smarthosts.googlecode.com/svn/trunk/hosts")
h.write(fh.read())
h.close

def Move():
Download()
os.system("mv /etc/hosts /etc/hosts.old")
os.system("mv hosts /etc/hosts")
print "更新完成,请重启浏览器"

def Rwnew():
os.system("mv etc/hosts.old /etc/hosts")
print "还原完成,请重启浏览器"

print "请以root权限运行"
print "请选择更新还是还原(1,更新;2,还原):"
i=int(input())

if i==1:
Move()
else:
if i==2:
Renew()
else:
print "EOF"

作者 hsyyf

《Linux下更新和备份Hosts》有10条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注