十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本篇内容主要讲解“用Shell脚本检查IP格式及mysql操作实例”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“用Shell脚本检查IP格式及mysql操作实例”吧!
宜良ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!还是cronjob的一部分,就是在Rails的定时任务里,后台交互运行
CheckIPAddress() { echo $1 |grep "^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$" > /dev/null if [ $? = 1 ]; then return 1 else a=`echo $1 | awk -F. '{print $1}'` b=`echo $1 | awk -F. '{print $2}'` c=`echo $1 | awk -F. '{print $3}'` d=`echo $1 | awk -F. '{print $4}'` #echo $a $b $c $d for loop in $a $b $c $d do if [ $loop -ge 255 ] || [ $loop -lt 0 ]; then return 2 fi done fi } ConfigureDefaultRegion() { echo "Please input Region ip" ret=1 while [ $ret != 0 ] do read region_ip CheckIPAddress $region_ip ret=$? #echo $ret if [ $ret = 1 ]; then echo "Wrong IP address, please reinput Region IP:" fi done /usr/bin/mysql -u root realworx_production -e "update regions set ip='$region_ip' where id=1" 1>/dev/null 2>/dev/null if [ $? = 0 ]; then /usr/bin/mysql -u root realworx_production -e "update config_params set val=1 where ident=55" 1>/dev/null 2>/dev/null echo "set '$region_ip' as Default and Admin Region IP" else val=`/usr/bin/mysql -u root realworx_production -e "select id from regions where ip='$region_ip'" | awk '{if ($1 != "id") print $1}'` /usr/bin/mysql -u root realworx_production -e "update config_params set val='$val' where ident=55" 1>/dev/null 2>/dev/null region_name=`/usr/bin/mysql -u root realworx_production -e "select name from regions where ip='$region_ip'" | awk '{if ($1 != "name") print $1}'` echo "IP already exists. So set '$region_name' as Admin Region. " fi echo "Region Setting Successfull." }
到此,相信大家对“用Shell脚本检查IP格式及mysql操作实例”有了更深的了解,不妨来实际操作一番吧!这里是创新互联建站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!