一、shell脚本编程

二、正则表达式

三、linux修改IP的方法

#!/bin/bash

cd /etc/network/

stty erase '^?'

write_interfaces()
{
echo "auto lo
iface lo inet loopback auto eth0
iface eth0 inet static
address $
netmask 255.255.255.0
gateway $
" > interfaces
} reboot_fun()
{
echo "reboot now?(Y/N)"
read reb_in if [[ ${reb_in} = $'Y' || ${reb_in} = $'y' ]]
then
echo "reboot now"
reboot
else
echo "pls reboot if you can not ping the IP"
fi
} ping_func()
{
ping -c $set_IP && result= || result=
if [ $result -eq ]
then
{
echo "set Ip conflict"
continue
IP_INPUT=
}
fi if [ $result -eq ]
then
{
echo "IP is ok:$set_IP" write_interfaces $set_IP $GateWay
/etc/init.d/networking reload
/etc/init.d/networking restart
echo "set ok"
IP_INPUT=
}
fi
} echo "set IP into the main.cpp"
IP_INPUT= while [ $IP_INPUT -eq ]
do
echo "input IP"
read set_IP -n if [[ $set_IP =~ ^([-]{,}|[-][-]|[-][-]|[-])\.([-]{,}|[-][-]|[-][-]|[-])\.([-]{,}|[-][-]|[-][-]|[-])\.([-]{,}|[-][-]|[-][-]|[-])$ ]]
then
echo "input gateway"
read GateWay arr_IP=${set_IP//./ }
arr_IP=($arr_IP)
arr_gw=${GateWay//./ }
arr_gw=($arr_gw) for arr in
do
if [ ${arr_IP[$arr]} == ${arr_gw[$arr]} ]
then
echo "arr_IP:${arr_IP[$arr]}"
else
echo "error IP :$set_IP"
continue
fi
done ping_func
fi
done reboot_fun

最新文章

  1. python 单例模式
  2. 【Hawk】入门教程(1)——从URL开始
  3. Swift - UIColor16进制编码与RGB格式互相转换
  4. 纯手写SpringMVC架构,用注解实现springmvc过程
  5. 更新系统没有mac dashboard 问题解决
  6. 一次由于开启 Safari 无痕浏览 引发的艰难“捉虫”事件
  7. python调用jar包类
  8. http请求方式和状态管理
  9. HDU 3265 Posters(线段树)
  10. JAVA 代理模式(Proxy)
  11. PDO--PHP Data Objects
  12. android ble蓝牙开发略解
  13. char与byte差异
  14. ajax格式,需要指定交互的data类型
  15. redis源码分析之事务Transaction(上)
  16. 初用MssqlOnLinux 【1】
  17. c++(八皇后)
  18. 在已有数据的表中添加id字段并且自增
  19. Bulb Switcher (leetcode java)
  20. SVG 使用marker画箭头(一)

热门文章

  1. JavaScript(jQuery)中的事件委托
  2. HttpClient使用小结
  3. SQLIO 磁盘測试工具參考
  4. 解决Js跨域访问的问题
  5. 轻量ORM-SqlRepoEx (十三)最佳实践
  6. C++获取毫秒级时间戳
  7. 查询优化百万条数据量的MySQL表
  8. Ajax数据获取(未完待续。。。)
  9. XML第一次简单入门(Lab分析)
  10. PHP-----PHP程序设计基础教程----第二章PHP基本语法