Community discussions

MikroTik App
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 881
Joined: Wed Mar 25, 2020 4:04 am

How to read also the flags of a data record? (bug in beta5?)

Mon May 18, 2020 1:55 pm

How to read also the flags of a data record?

For example:
/interface bridge host print                                                         
Flags: D - DYNAMIC; L - LOCAL; E - EXTERNAL
Columns: MAC-ADDRESS, ON-INTERFACE, BRIDGE
  #       MAC-ADDRESS        ON-INTE  BRIDGE
  0  D E  00:21:86:A1:63:56  ether9   bridge
  1  D E  20:1A:06:5F:C0:3D  ether15  bridge
  2  D E  24:A4:3C:06:6C:2D  ether1   bridge
  3  DL   C4:AD:34:78:E1:88  bridge   bridge
  4  DL   C4:AD:34:78:E1:90  ether9   bridge
  5  DL   C4:AD:34:78:E1:96  ether15  bridge

I need to read all fields of these data records, incl the flags. I tried the following, but as can be seen
the flags are missing:
:foreach i in=[/interface bridge host print detail as-value] do={ :put $i; }                       
.id=*5c;bridge=bridge;comment=;interface=ether9;mac-address=00:21:86:A1:63:56;on-interface=ether9
.id=*5a;bridge=bridge;comment=;interface=ether15;mac-address=20:1A:06:5F:C0:3D;on-interface=ether15
.id=*57;bridge=bridge;comment=;interface=ether1;mac-address=24:A4:3C:06:6C:2D;on-interface=ether1
.id=*5b;bridge=bridge;comment=;interface=bridge;mac-address=C4:AD:34:78:E1:88;on-interface=bridge
.id=*58;bridge=bridge;comment=;interface=ether9;mac-address=C4:AD:34:78:E1:90;on-interface=ether9
.id=*59;bridge=bridge;comment=;interface=ether15;mac-address=C4:AD:34:78:E1:96;on-interface=ether15

Btw, it applies not only to the above example, but rather generally to all such data that has flags in its normal output.

Is this a bug in beta5?

How can I read these flags?

If it's currently not possible then I propose that it should be added into the next beta version.

PS: the above example was tested on a CRS326 switch with RouterOS 7.0beta5.
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1099
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: How to read also the flags of a data record? (bug in beta5?)  [SOLVED]

Fri May 22, 2020 10:44 am

The command print is (mostly) for terminal output.

Does something like this work for you?
:foreach i in=[ /interface bridge host find ] do={ :put [ /interface bridge host get $i ]; }
BTW, why do you expect everything to be a bug?
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 881
Joined: Wed Mar 25, 2020 4:04 am

Re: How to read also the flags of a data record? (bug in beta5?)

Fri May 22, 2020 1:28 pm

The command print is (mostly) for terminal output.

Does something like this work for you?
:foreach i in=[ /interface bridge host find ] do={ :put [ /interface bridge host get $i ]; }

Yes, that's indeed the solution, though with an IMHO unintuitive/unexpected syntax. But never mind, it works. Thx.

:foreach i in=[ /interface bridge host find ] do={ :put [ /interface bridge host get $i ]; }
.id=*75;bridge=bridge;disabled=false;dynamic=true;external=true;interface=ether15;invalid=false;local=false;mac-address=20:1A:06:5F:C0:3D;on-interface=ether15
.id=*72;bridge=bridge;disabled=false;dynamic=true;external=true;interface=ether1;invalid=false;local=false;mac-address=24:A4:3C:06:6C:2D;on-interface=ether1
.id=*76;bridge=bridge;disabled=false;dynamic=true;external=false;interface=bridge;invalid=false;local=true;mac-address=C4:AD:34:78:E1:88;on-interface=bridge
.id=*73;bridge=bridge;disabled=false;dynamic=true;external=false;interface=ether9;invalid=false;local=true;mac-address=C4:AD:34:78:E1:90;on-interface=ether9
.id=*74;bridge=bridge;disabled=false;dynamic=true;external=false;interface=ether15;invalid=false;local=true;mac-address=C4:AD:34:78:E1:96;on-interface=ether15
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1099
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: How to read also the flags of a data record? (bug in beta5?)

Fri May 22, 2020 2:57 pm

IMHO it is very intuitive if you are used to it. Scripting is one of the reasons I do love RouterOS.
 
User avatar
mutluit
Forum Veteran
Forum Veteran
Topic Author
Posts: 881
Joined: Wed Mar 25, 2020 4:04 am

Re: How to read also the flags of a data record? (bug in beta5?)

Fri May 22, 2020 3:09 pm

@eworm, I like the following shorter variant:
/interface/bridge/host
:foreach i in=[find] do={ :put [ get $i; ] }
.id=*7e;bridge=bridge;disabled=false;dynamic=true;external=true;interface=ether15;invalid=false;local=false;mac-address=20:1A:06:5F:C0:3D;on-interface=ether15
.id=*80;bridge=bridge;disabled=false;dynamic=true;external=true;interface=ether1;invalid=false;local=false;mac-address=24:A4:3C:06:6C:2D;on-interface=ether1
.id=*7f;bridge=bridge;disabled=false;dynamic=true;external=false;interface=bridge;invalid=false;local=true;mac-address=C4:AD:34:78:E1:88;on-interface=bridge
.id=*7c;bridge=bridge;disabled=false;dynamic=true;external=false;interface=ether9;invalid=false;local=true;mac-address=C4:AD:34:78:E1:90;on-interface=ether9
.id=*7d;bridge=bridge;disabled=false;dynamic=true;external=false;interface=ether15;invalid=false;local=true;mac-address=C4:AD:34:78:E1:96;on-interface=ether15
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1099
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: How to read also the flags of a data record? (bug in beta5?)

Fri May 22, 2020 3:28 pm

I do not, and here is why:
If you have complex code depending on relative paths it tends to break if you move fragments of code up or down.