Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell Mikrotic路由器上的Lua脚本_Shell_Lua_Router_Mikrotik_Router Os - Fatal编程技术网

Shell Mikrotic路由器上的Lua脚本

Shell Mikrotic路由器上的Lua脚本,shell,lua,router,mikrotik,router-os,Shell,Lua,Router,Mikrotik,Router Os,我是LUA的新手,所以对我放松点。 我有以下代码,应该运行到mikrotik路由器中。 你能告诉我它是干什么的吗 :local content :local i #For each mangle in the list :foreach i in=[/ip firewall mangle find comment !=""] do={ #Pull comment out of queue and divide up accordingly :set content [/ip firew

我是LUA的新手,所以对我放松点。 我有以下代码,应该运行到mikrotik路由器中。 你能告诉我它是干什么的吗

:local content
:local i
#For each mangle in the list
:foreach i in=[/ip firewall mangle find comment !=""] do={

#Pull comment out of queue and divide up accordingly
    :set content [/ip firewall mangle get $i comment]
:if ([:find $content "!"] != "") do={
        :local pos1 [:find $content "!"]
        :local pos4 [:len $content]
        :local pos2 ([:find [:pick $content ($pos1+1) $pos4] "!"]+($pos1+1))
        :local pos3 ([:find [:pick $content ($pos2+1) $pos4] "!"]+($pos2+1))

这是一个Mikrotik脚本,它在firewall mangle rules中搜索带有注释的规则,并查找带有感叹号“!”的注释

变量
pos1
pos2
pos3
的第一、第二和第三个位置

例如: 如果有这样的注释:
a!Bcde!fg

变量将是:

pos1=1    pos2=3    pos3=7
位置从零开始,所以第一个位置是0,第二个位置是1


@我以前读过它。。。我想知道细节。+1因为你是第一个问题的新用户:D