Community discussions

MikroTik App
 
User avatar
robmaltsystems
Long time Member
Long time Member
Topic Author
Posts: 555
Joined: Fri Jun 21, 2019 12:04 pm

Why is there a "*" in front of the interface number

Wed Apr 21, 2021 10:20 am

The following command logs the number of each of the interfaces and produces the output below:
:foreach k in=[/interface find] do={:log info $k}

Image

Why is there a "*" in front of each number? It doesn't appear to do any harm because this lists the names of the scripts:
:foreach k in=[/interface find] do={:log info [/interface get $k name]}

However, if you try this command you get an error "no such item":
:log info [/interface get $1 name]
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Why is there a "*" in front of the interface number

Wed Apr 21, 2021 12:45 pm

:foreach k in=[/interface find] do={:log info $k}
= for each interfae you find, put the ".id" on the log
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Why is there a "*" in front of the interface number

Wed Apr 21, 2021 12:48 pm

:foreach k in=[/interface find] do={:log info [/interface get $k name]}
= for each interfae you find, put the interface name with the id ".id" on the log
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Why is there a "*" in front of the interface number

Wed Apr 21, 2021 12:50 pm

:log info [/interface get $1 name]
= log the name of interface named same as "$1" variable

(and on this case "name" and $1 are the same thing, like "how is named John?", the name is on the question...)

you must add something in the $1 var like:
:global 1 "ether1"
Last edited by rextended on Wed Apr 21, 2021 1:03 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Why is there a "*" in front of the interface number

Wed Apr 21, 2021 12:57 pm

*1 = database entry ID on the database interface list


array of interface ID (the right name is ".id")
:put [/interface find]
for example, if you do on CLI:
:put [/interface get *1]
you get something like:
.id=*1;actual-mtu=1500;default-name=ether1; ...etc...
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Why is there a "*" in front of the interface number

Wed Apr 21, 2021 1:05 pm

You can use "name" of the interface for retrieve something:
:log info [/interface get ether1 disabled]
Or you can use the ".id":
:log info [/interface get *1 disabled]
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Why is there a "*" in front of the interface number

Wed Apr 21, 2021 10:09 pm

5 post in 20 minutes :)
You know you can use the Edit button.

Mikrotik does not write why they add a * in front of an ID, but here you see some info.

https://wiki.mikrotik.com/wiki/Manual:Scripting

id (internal ID) - hexadecimal value prefixed by '*' sign. Each menu item has assigned unique number - internal ID;
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7041
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Why is there a "*" in front of the interface number

Thu Apr 22, 2021 1:13 pm

Mikrotik does not write why they add a * in front of an ID, but here you see some info.
So that you'll never confuse internal ids with temporary ids generated by console print.

Who is online

Users browsing this forum: JDF and 9 guests