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) |
<script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/buttonLite.js#style=-1&uuid=&pophcol=3&lang=zh"></script> <script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/bshareC0.js"></script>
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
相关热门文章
给主人留下些什么吧!~~
评论热议