一个在linxu自动切换ip的脚本
最近的爬虫是在linux下运行的,使用的是云立方的代理服务器,需要自动切换一下ip。
#!/bin/bash
# coding:utf8
aa="sources.list"
#主流程
if [ -n $aa ];then
touch $aa
echo "1->ali(ubuntu16) 2->ali(ubuntu14) 3->nyist(ubuntu14)"
echo "choose :"
read sou_name #由键盘读入源类型,切换源
if [ "$sou_name" = 1 ];then
echo "${aa}文件已经创建完毕。。。开始写入${sou_name}源地址"
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse " >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse" >> $aa
elif [ "$sou_name" = 2 ];then
echo "${aa}文件已经创建完毕。。。开始写入${sou_name}源地址"
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" > $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> $aa
elif [ "$sou_name" = 3 ];then
echo "${aa}文件已经创建完毕。。。开始写入${sou_name}源地址"
echo "deb http://59.69.128.21/ubuntu/ trusty main restricted universe multiverse" > $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-security main restricted universe multiverse" >> $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-updates main restricted universe multiverse" >> $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-proposed main restricted universe multiverse" >> $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-backports main restricted universe multiverse" >> $aa
else
exit 1
fi
rm -rf /etc/apt/sources.list
mv $aa /etc/apt/
else
echo "error"
fi
#测试写入源是否成功
if test -s /etc/apt/sources.list;then
cat /etc/apt/sources.list
apt-get update
echo "Do you need to upgrade the software? y/n"
read option
if [ "$option" = 'y' ];then
apt-get upgrade -y
else
echo "not upgrade"
fi
else
echo "empty"
fi
一个在linxu自动切换ip的脚本的更多相关文章
- window自动切换ip的脚本
因为总要切换ip,所以百度了一下脚本 如下http://jingyan.baidu.com/article/d2b1d1029d21b95c7e37d4fa.html 动态ip netsh inter ...
- 写一个shell,自动执行jmeter测试脚本
贡献一个自己写的shell脚本,很简单,但又可以高效率的自动执行jmeter压测脚本. #!/bin/bash #author:zhangyl #version:V1 #该脚本放置于压测脚本的上一层目 ...
- Ubuntu 设定壁纸自动切换的shell脚本
升级到Ubuntu14.04后,感觉bug的确比12.04少多了.顶部任务栏支持半透明效果,所以整个桌面也看上去漂亮了很多.这样的桌面也是值得瞎捣鼓一下的,想到换壁纸,但是没找到设定动态更换壁纸的选项 ...
- 一个简单爬免费代理IP的脚本
- 【我们开发有力量之二】利用javascript制作批量网络投票机器人(自动改IP)
帮朋友忙网络投票,粗粗地看了下,投票没有什么限制,仅有一个ip校验:每天每个ip仅能投票一次. 也就是说,可以写一个程序,自动更换IP地址(伪造IP地址),实现批量刷票的目的.于是我写了一个投票机器人 ...
- IP自动切换脚本
@echo off & cls & color 47 & mode con cols=80 lines=25 & title [IP自动切换工具]clsecho. ec ...
- 脚本设置IP bat 命令行设置自动获取IP和固定IP
由于办公室网络需要固定IP和DNS才能上网, 在连接公共网络或者家里又需要自动获取IP和DNS才能上网. 频繁手动切换很麻烦,就搞了两个脚本一键设置. 1.新建文本文件, 命名为固定IP.bat 复制 ...
- Nginx+keepalived 脚本安装主从双机热备自动切换解决方案
Nginx+keepalived 脚本安装主从双机热备自动切换解决方案 2013-07-02 19:24:13 标签:filesnginx keepalived 原创作品,允许转载,转载时请务必以超链 ...
- windows10 自动配置切换IP
办公室与家里的ip网段不一样.每次都要来回修改本地无线WLAN IP段.写了个脚本bat,自动配置WLAN IP,方便切换. 建立 auto-set-ip.bat,保存格式需为ANSI,否则中文会乱码 ...
随机推荐
- Lab 3-4
Analyze the malware found in the file Lab03-04.exe using basic dynamic analysis tools. (This program ...
- apiCloud 上拉加载
api.addEventListener({ name:'scrolltobottom', extra:{threshold:} }, function(ret, err){ //上拉加载时需要加载的 ...
- hihocoder 1513 小Hi的烦恼 (bitset优化)
大意: n个人, 5门课, 给定每个人每门课的排名, 对于每个人输出有多少人5门课都比他差. 明显是个5维偏序问题, 题目有保证排名均不同, 可以用bitset优化为$O(\frac{n^2}{\om ...
- GPLT L2-014 列车调度
题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805063166312448 分析:明显从右到左列车的序号需要依 ...
- 『TensorFlow』分布式训练_其一_逻辑梳理
1,PS-worker架构 将模型维护和训练计算解耦合,将模型训练分为两个作业(job): 模型相关作业,模型参数存储.分发.汇总.更新,有由PS执行 训练相关作业,包含推理计算.梯度计算(正向/反向 ...
- bzoj3676: [Apio2014]回文串 pam
题意:字符串s.我们定义s的一个子串t的"出 现值"为t在s中的出现次数乘以t的长度.请你求出s的所有回文子串中的最 大出现值. 题解:pam板子题 //cnt数组表示该节点代表的 ...
- 文件名简体转繁体bat
@echo off rem 指定文件夹路径 set "fd=D:\下载的图片" rem 0为转换文件名,1为转换文件夹名,2为同时转换文件名和文件夹名 set f=0 rem 0为 ...
- js定义类
以下是es5标准里定义类的方法: function Point(x,y){ this.x=x; this.y=y; } Point.prototype.toString=function(){ ret ...
- position属性的总结
static 默认.位置设置为 static 的元素,它始终会处于页面流给予的位置(static 元素会忽略任何 top.bottom.left 或 right 声明). relative 位置被设置 ...
- js中去掉字符串的空格、回车换行
//例如下面这个json串,中间的\n表示换行 var str = "{' retmsg':'success ',\n' trans_date':' 20170906'}"; co ...