Sorry about the basic question.
Why does the following command print only ether 2:
/interface print where name=ether2
but:
/interface print where [find name=ether2]
result in listing all interfaces?
Do you mean that:Because where property of print command expects textual argument but [ find where ...] provides list of interfaces in format alien to where ... and print simply ignores it (try running "/interface/print where" ).
Well, this is actually a bit more complicated.I would add ...
The older I get the more I bump into the situation, that I believe is axiomatic, whereby everything is far far more complicated than one knows at the moment.Almost correct, except that there are two kinds of IDs - the internal one that stays the same as long as the object exists and is shown as *1fe or something alike (a 32-bit number in hexadecimal representation prefixed with an asterisk). These are the IDs that [find ...] returns. As @mkx has already said, it actually always returns a list, try the following:
:put [/interface/ethernet/find where name~"ether"]
:put [:typeof [/interface/ethernet/find where name~"ether"]]
[admin@729hAPax3] > :put [/interface/ethernet/find where name~"ether"]
*2;*3;*4;*5;*6
[admin@729hAPax3] > :put [:typeof [/interface/ethernet/find where name~"ether"]]
array
But even if you restrict the condition to just a single item, find ... still returns a list, except that put (and many other operations) performs an automatic conversion from a single-item list (array) to a scalar:
:put [/interface/ethernet/find where name~"ether1"]
:put ([/interface/ethernet/find where name~"ether1"]->0)
:put [:typeof [/interface/ethernet/find where name~"ether1"]]
[admin@729hAPax3] > :put [/interface/ethernet/find where name~"ether1"]
*2
[admin@729hAPax3] > :put ([/interface/ethernet/find where name~"ether1"]->0)
*2
[admin@729hAPax3] > :put [:typeof [/interface/ethernet/find where name~"ether1"]]
array
Results:Each print assigns user-friendly aliases to the internal IDs, in the form of numbers in decimal representation; these aliases are only valid in the shell where they have been assigned and only until the next print of the same configuration branch. Try the following:
/ip/firewall/mangle/add chain=test917 dst-address=1.1.1.1 action=passthrough
/ip/firewall/mangle/add chain=test917 dst-address=2.2.2.2 action=passthrough
/ip/firewall/mangle/add chain=test917 dst-address=3.3.3.3 action=passthrough
A jump to chain test917 is (hopefully) not used anywhere in mangle, so these rules are never actually used.
Now do
/ip/firewall/mangle/print where chain=test917
- it shows you those items numbered 0, 1, and 2.
[admin@729hAPax3] > ip/firewall/mangle/print where chain=test917
Flags: X - disabled, I - invalid; D - dynamic
0 chain=test917 action=passthrough dst-address=1.1.1.1
1 chain=test917 action=passthrough dst-address=2.2.2.2
2 chain=test917 action=passthrough dst-address=3.3.3.3
I certainly could be doing something wrong, but I don't think it is working like that for me./ip/firewall/mangle remove 0 will remove the first one (with dst-address=1.1.1.1), but another /ip/firewall/mangle/print where chain=test917 will assign the "user-friendly ID" 0 to the first remaining one (with dst-address=2.2.2.2).
[admin@729hAPax3] > /ip/firewall/mangle remove 0
[admin@729hAPax3] > /ip/firewall/mangle remove 0
no such item (4)
[admin@729hAPax3] > ip/firewall/mangle/print where chain=test917
Flags: X - disabled, I - invalid; D - dynamic
1 chain=test917 action=passthrough dst-address=2.2.2.2
2 chain=test917 action=passthrough dst-address=3.3.3.3
[admin@729hAPax3] > /ip/firewall/mangle remove 0
no such item (4)
[admin@729hAPax3] >
[admin@729hAPax3] > ip/firewall/mangle/print where chain=test917
Flags: X - disabled, I - invalid; D - dynamic
1 chain=test917 action=passthrough dst-address=2.2.2.2
2 chain=test917 action=passthrough dst-address=3.3.3.3
A list is implicitly also an array indexed by integers starting from 0. So ($thisList->0) is a reference to the first ("zeroth") element of thisList. To make it even crazier, you can mix different types of indice in the same array, more to find in the scripting documentation.I don't understand what the addition of "->0" does.
It's not you, it's the developers who keep "making it even better". I have specially tested it on ROS 7.16.2 before posting and it worked the same like in ROS 6, i.e. the user-friendly IDs were assigned from scratch with each print. I have double-checked just now:I certainly could be doing something wrong, but I don't think it is working like that for me.
falseprovides list of interfaces in format alien to where ... and print simply ignores it
/interface print where [find name=ether2]/interface print where [find name=ether2]
result in listing all interfaces?
/interface print where ([:tobool [/interface find where name="ether2"]] = true)
/interface print where (true = true)
/interface print where [find name=ether666]
/interface print where name="ether2"
/interface print where .id=[find where name="ether2"]
/interface print where name=[get [find where name="ether2"] name]
... and how are you going to conclude ?
I'll start by saying that ...
Leave me the time to check and finish the post...![]()
![]()
falseprovides list of interfaces in format alien to where ... and print simply ignores it
Did you try it? When I tried it, it printed out all interfaces ... so how do you put it in your extensive explanation about boolean arithmetics (other than "NULL is true" logic)?(try running "/interface/print where" )
Do error, is not valid. You add a space after where for sure (or more probably you remove all characters of a previous command but not the space).(try running "/interface/print where" )
# on this line is NOT present anything after where: [] > /interface print where expected end of command (line 1 column 18) # on this line is present one space after where: [] > /interface print where Flags: R - RUNNING Columns: NAME, TYPE, ACTUAL-MTU, L2MTU, MAC-ADDRESS # NAME TYPE ACTUAL-MTU L2MTU MAC-ADDRESS 0 R ether1 ether 1500 00:0C:29:DE:AD:BE 1 R bri-pppoe-test bridge 1500 65535 00:0C:29:DE:AD:EF 2 R lo loopback 65536 00:00:00:00:00:00 [] > :put [:parse "/interface print where"] expected end of command (line 1 column 18) [] > :put [:parse "/interface print where "] 7.16.2: (evl /interface/print) 6.48.7: (eval /interface print) [code2]
Very cool!Do error, is not valid. You add a space after where for sure (or more probably you remove all characters of a previous command but not the space).
Simply compiler do error if where is not followed by something, and ignore it if is followed with a space....
terminal 7.16.2 and 6.48.7 code
# on this line is NOT present anything after where: [] > /interface print where expected end of command (line 1 column 18) # on this line is present one space after where: [] > /interface print where Flags: R - RUNNING Columns: NAME, TYPE, ACTUAL-MTU, L2MTU, MAC-ADDRESS # NAME TYPE ACTUAL-MTU L2MTU MAC-ADDRESS 0 R ether1 ether 1500 00:0C:29:DE:AD:BE 1 R bri-pppoe-test bridge 1500 65535 00:0C:29:DE:AD:EF 2 R lo loopback 65536 00:00:00:00:00:00 [] > :put [:parse "/interface print where"] expected end of command (line 1 column 18) [] > :put [:parse "/interface print where "] 7.16.2: (evl /interface/print) 6.48.7: (eval /interface print) [code2]
[admin@729hAPax3] > /interface print where
expected end of command (line 1 column 18)
[admin@729hAPax3] >
[admin@729hAPax3] > /interface print where
Flags: X - DISABLED; R - RUNNING; S - SLAVE
Columns: NAME, TYPE, ACTUAL-MTU, L2MTU, MAX-L2MTU, MAC-ADDRESS
# NAME TYPE ACTUAL-MTU L2MTU MAX-L2MTU MAC-ADDRESS
0 R ether1 ether 1500 1568 9214 D4:01:C3:C0:82:CE
1 S ether2 ether 1500 1568 9214 D4:01:C3:C0:82:CF
2 S ether3 ether 1500 1568 9214 D4:01:C3:C0:82:D0
3 S ether4 ether 1500 1568 9214 D4:01:C3:C0:82:D1
4 S ether5 ether 1500 1568 9214 D4:01:C3:C0:82:D2
5 S 2point4 wifi 1500 1560 1560 D6:01:C3:C0:82:D3
6 X Guest-wifi1 wifi 1560 1560 D6:01:C3:C0:82:D6
7 X Guest-wifi2 wifi 1560 1560 D6:01:C3:C0:82:D7
8 Guest2g wifi 1500 1560 1560 D6:01:C3:C0:82:D4
9 Guest5g wifi 1500 1560 1560 D6:01:C3:C0:82:D5
;;; defconf
10 R bridge bridge 1500 1560 D4:01:C3:C0:82:CF
11 R lo loopback 65536 00:00:00:00:00:00
12 S wifi1 wifi 1500 1560 1560 D4:01:C3:C0:82:D3
13 S wifi2 wifi 1500 1560 1560 D4:01:C3:C0:82:D4
14 R wireguard1 wg 1420
[admin@729hAPax3] >
[admin@729hAPax3] > :put [:parse "/interface print where"]
expected end of command (line 1 column 18)
[admin@729hAPax3] >
[admin@729hAPax3] >
[admin@729hAPax3] > :put [:parse "/interface print where "]
(evl /interface/print)
[admin@729hAPax3] >