Having real trouple searching this one up.. as the search terms are 2 letters or operators that aren't accepted by the Forum.
Trying to write a script that does a Find for <value> OR <value>. In this instance, trying to use the same variable, just with different values.
test script isThis produces an output where it finds all interfaces and outputs them in terminal, unless it is named ether5.
This one produces similar output, but instead of printing all interfaces, only prints ones with names similar to ether, sfp or combo (general ethernet interfaces in Mikrotik).
The problem I have is that I want to have multiple "name!=ether5" entires, but at this time have to have multiple entires. I would have expected "&&" (and) and "||" (or) to work with the operation, but cannot get the desired output. Usually it results in the "not" variable failing.
e.g of code that works...This does as required - but having multiple <variable>!=<value> is really Yuck.
e.g of what I would expect to workorSo, My question is if there is any way to "or" a "find" command, without having to fully script out the <variable>!=<value> multiple times per line. Trying to get it to a point where I can potentially array a script using similar code.
As you can well see here - the is already a type of "or" for this - but just cannot get anything similar for "not"
Trying to write a script that does a Find for <value> OR <value>. In this instance, trying to use the same variable, just with different values.
test script is
Code:
[/foreach count in=[/interface find name!=ether5] do={:put [/interface get value-name=name number=$count] }]
Code:
[/foreach count in=[/interface find name!=ether5 name~"(ether|sfp|combo)"] do={:put [/interface get value-name=name number=$count] }]
The problem I have is that I want to have multiple "name!=ether5" entires, but at this time have to have multiple entires. I would have expected "&&" (and) and "||" (or) to work with the operation, but cannot get the desired output. Usually it results in the "not" variable failing.
e.g of code that works...
Code:
[/foreach count in=[/interface find name!=ether5 name!=ether2 name~"(ether|sfp|combo)"] do={:put [/interface get value-name=name number=$count] }]
e.g of what I would expect to work
Code:
[/foreach count in=[/interface find name!="ether5"||"ether2" name~"(ether|sfp|combo)"] do={:put [/interface get value-name=name number=$count] }]
Code:
[/foreach count in=[/interface find name!="(ether5|ether2)" name~"(ether|sfp|combo)"] do={:put [/interface get value-name=name number=$count] }]
As you can well see here - the
Code:
name~"(ether|sfp|combo)"
Statistics: Posted by gammy69er — Mon Feb 12, 2024 2:58 am