probably yes, but a concrete exmple for work on?If I have an interface list with include and/or exclude references, is there a way to it to list all members in a script?
/interface list add include=static name=test2 add include=test2 name=test1 /interface list member add interface=wlan1 list=test1
/interface list :put [get [find where name=test1] include] >>> test2 /interface list :put [get [find where name=test2] include] >>> static (reserved keyword) /interface :put [get ([find where !dynamic]->0) name] >>> ether1 /interface list member :put ([get [find where list=test1]->0) interface] >>> wlan1 /interface list member :put [get ([find where list=test2]->0) interface] >>> (nothing)
/interface list add name=EXAMPLE include=WAN,dynamic exclude=LAN,static"
My understanding is that when he has a list like the default "static" or "dynamic" lists, he wants to know which interfaces are member of that.
He does not want to get the word "static", he wants a list of all interfaces that are considered static.
/interface print where !dynamic
This was of course only an example. The actual situation is more complex than that, see the post by Amm0.My understanding is that when he has a list like the default "static" or "dynamic" lists, he wants to know which interfaces are member of that.
He does not want to get the word "static", he wants a list of all interfaces that are considered static.Code:Select all/interface print where !dynamic
# keyword: all /interface ; :foreach item in=[find] do={:put [get $item name]} # keyword: dynamic /interface ; :foreach item in=[find where dynamic] do={:put [get $item name]} # keyword: none # really.... # keyword: static /interface ; :foreach item in=[find where !dynamic] do={:put [get $item name]}
Yes, but without a concrete example, can't be clear what the user want do....This was of course only an example. The actual situation is more complex than that, see the post by Amm0.
Also note that you can create your own dynamic lists, e.g. from a PPP profile.
I understand the problem as if you do something like thisHow do you get the list of members of the EXAMPLE list?Code:Select all/interface list add name=EXAMPLE include=WAN,dynamic exclude=LAN,static"
Not saying a script couldn'tpotentiallyget some list, but the lists can actually have multiple levels of hierechary too (e.g. /interface/list/add name=EXAMPLE2 include=EXAMPLE exclude=dynamic), it's not so simple.
IMO, issue is /interface/list/member/print only shows the actual interface assignment, but NOT ones that are "include=" by reference in the list. Ideally, the print show the results of the EXAMPLE list AFTER applying the include= & exclude= – like how "D" items appear in /ip/firewall/address-list for DNS names resolved.
/interface :foreach item in=[find where dynamic or ([:len [:find [:tostr [list member find where list="WAN"]] [:tostr $".id"]]] > 0) ] do={ :put [get $item name] }
Even if ridiculous, you might still what to see just how ridiculous it is, somehow. These are typically used in a firewall, so as audit, be would good to know definitively what the actual interfaces the firewall would consider after processing include=/exclude=. Also why I stop using include= myself since "resolving by hand" get tricky quickly.without going into the ridiculousness of 3 or more linked lists, but remaining in practice...
and without going into the ridiculousness that one member of LAN is also a member of the WAN....
I think it is quite clear what he wants. And in general I do not like the "why would you want that??" approach to answering questions.Yes, but without a concrete example, can't be clear what the user want do....
同意,在Winbox上市/ Webfig wh将更清楚ich list includes/excludes interfacesYes, it would certainly be preferable when there was a read-only property of each list that returns the actual members of that list.
Sorry, but in what sense?I think it is quite clear what he wants. And in general I do not like the "why would you want that??" approach to answering questions.Yes, but without a concrete example, can't be clear what the user want do....
/interface list add name=CHILD1 include=dynamic /interface list add name=CHILD2 include=static /interface list add name=ROOT include=CHILD1,CHILD2 :global RESOLVEIFLIST do={ :global RESOLVEIFLIST :local iflist $1 :local mems :if ([:typeof $2] = "array") do={ :set mems $2 } else={ :set mems [:toarray ""]} #:put $iflist :set iflist [/interface list get [find name=$iflist]] #:put $iflist :if ([:typeof $iflist] != "array") do={ :error "list not found" } :do on-error={} { :set mems ($mems, [/interface list member get [find list=($iflist->"name")]]) } :local inc ($iflist->"include") :foreach imem in=$inc do={ #:put "imem = $imem" :if ($imem = "dynamic") do={ :foreach dname in=[/interface find where dynamic] do={:set mems ($mems,[/interface/get $dname name])} } else={ :if ($imem = "static") do={ :foreach dname in=[/interface find where !dynamic] do={:set mems ($mems,[/interface/get $dname name])} } else={ :set mems [$RESOLVEIFLIST $imem $mems] }} } :return $mems # todo: remove exclude= ... # :local excl ($iflist->"exclude") } :put [$RESOLVEIFLIST ROOT]