Bash check IP and port

来源:互联网 发布:淘宝客服旺旺号是多少 编辑:程序博客网 时间:2024/05/18 02:25
33 #check arguments
34 
35 #check ip
36 pattern_ip="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))$"
37 #pattern_ip="^((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}(1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$"
38 
39 if [[ !(($1 =$pattern_ip&& ($3 =$pattern_ip)) ]] ; then
40     echo "from_ip or to_ip has errors!"
41     exit 0
42 fi
43 
44 #check port
45 pattern_port="^([0-9]{1,4}|[1-5][0-9]{4}|6[0-5]{2}[0-3][0-5])$"
46 if [[ !($2 =$pattern_port]]; then
47     echo "port has erros!"
48     exit 0;
49 fi

阅读(289) | 评论(0) | 转发(0) |
0

上一篇:Use clonezilla to clone and restore disk

下一篇:Linux 内核中的 GCC 特性(转)

相关热门文章
  • linux 常见服务端口
  • 什么是shell
  • linux socket的bug??
  • linux的线程是否受到了保护?...
  • 一个适用于windows和linux的抓...
  • shell将变量当命令执行问题【...
  • 深入理解Linux网络技术内幕-设...
  • 高性能网络I/O框架-netmap源码...
  • 深入理解Linux网络技术内幕-...
  • Linux下bin文件的安装
给主人留下些什么吧!~~
原创粉丝点击