MikroTik 脚本:简单 foreach 示例
以下示例使用 MikroTik 脚本遍历所有 ethernet 接口并打印接口名称:
mikrotik-scripting-simple-foreach-example.rsc
foreach v in=[/interface/ethernet find] do={
:put [/interface/ethernet get $v value-name=name]
}示例输出:
mikrotik_foreach_output.txt
[admin@MySwitch] > foreach v in=[/interface/ethernet find] do={:put [/interface/ethernet get $v value-name=name]}
ether1
sfp-CoreSwitch-Uplink
sfp-sfpplus3
sfp-NAS
sfp-Virtualization
sfp-WAN
sfp-sfpplus4
sfp-sfpplus7
sfp-sfpplus8Check out similar posts by category:
MikroTik
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow