This topic created in 4218 days ago, the information mentioned may be changed or developed.
自己想写一个自动从GitHub上更新最新的Hosts文件到本地的脚本,奈何完全不会Unix的脚本编写。
希望诸位能提供个简单教程的网页
或者直接帮我写一个吧(不会被说伸手党吧)
在终端自己输入的命令如下:
cd 本地的Git文件夹路径
git pull
sudo cp imouto.host.txt /etc/hosts
Supplement 1 Oct 25, 2014 脚本写好了,果然只要吧命令行一条条列出来就行了
附上脚本内容及GitHub地址:
-------文件名---------
updateHosts.sh
-------文件内容----------
#! /bin/bash
cd /Users/Jeff/Documents/Git/imouto.host
git pull
sudo cp imouto.host.txt /etc/hosts
我在用的hosts地址:https://github.com/zxdrive/imouto.host
蛮好用的,基本Google,FB,Twitter等都不用GoAgent,VPN了
Supplement 2 Oct 25, 2014 现在要做的就是把这个脚本定时运行,这个还得去查查看
9 replies 2014-10-25 15:16:50 +08:00  | | 1 hjc4869 Oct 25, 2014 学一下bash脚本,挺容易的。 |
 | | 3 Busy Oct 25, 2014 三个命令写成三行,放入一个文件中,给他执行权限,不就一个脚本嘛 看下 shell 相关的知识 |
 | | 5 Livid Oct 25, 2014 你可以考虑先稍微学一下 vi 编辑器。 |
 | | 6 banbanchs Oct 25, 2014 wget rawgithubXXX -O /etc/hosts 加到crontab,要root权限 |
 | | 8 Vicia Oct 25, 2014 Keyboard Maestro可以定时运行脚本。 |
 | | 9 skydiver Oct 25, 2014 via Android 直接软链到/etc/hosts就行了,以后每次pull |