LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 766|回复: 3

请高手给解释一下此脚本的意思?

[复制链接]
发表于 2006-7-27 11:54:20 | 显示全部楼层 |阅读模式
这是一个Iptables的脚本,对其不解,所以请高手帮忙,内容如下:
#!/bin/sh
IN_TCP_PORTALLOWED="ssh,192.168.8.1 domain smtp http https"
for i in $IN_TCP_PORTALLOWED ; do
   IFS=','
   set $i

   unset IFS ipt_option
   port="$1"

   [ -n "$2" ] && ipt_option="-s `echo $2 | sed 's/^!/! /'`"
   iptables -A INPUT -p tcp $ipt_option --dport $port \
         --syn -m state --state NEW -j ACCEPT
done
我想问的问题如下:
1: set $i 是什么意思?
2: unset IFS ipt_option 中的ipt_option从何而来?什么意思?unset ipt_option之后其值会发生什么变化?
感谢!
 楼主| 发表于 2006-7-27 19:59:18 | 显示全部楼层
为什么?
各位高手!
帮帮忙!
回复 支持 反对

使用道具 举报

发表于 2006-7-28 02:12:27 | 显示全部楼层
1. set $i means assign the value of $i to positional argus $1, $2...
2. unset will clean the value of a variable. because the whole thing runs in a loop and using the same variable, so everytime it loops to the next, the value of the variable should be cleaned and then assigned to a new value.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-28 10:57:19 | 显示全部楼层
I see.
Thanks a lot!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表