Community discussions

MikroTik App
 
User avatar
javajox
newbie
Topic Author
Posts: 44
Joined: Fri Aug 23, 2013 9:32 pm

How to obtain the list of route marks programmatically

Thu Dec 28, 2017 7:44 pm

Hello Guys,

I'm writing a complex RouterOS script right now. I need to obtain the list of route marks, my Mikrotik router has 3 route marks, let say "route_mark1", "route_mark2" and "route_mark3". So for now I couldn't find the commands which will retrieve this list. In the end I should have a local variable as an array initialized with this list:
:local localRouteMarks {"route_mark1", "route_mark2", "route_mark3"};

Could someone help me and provide the piece of code which I need ?

Thank you
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1782
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: How to obtain the list of route marks programmatically  [SOLVED]

Sat Dec 30, 2017 10:55 pm

Have a look at this post: using some of these commands you could build an array with all marks: viewtopic.php?f=9&t=53157&p=374555#p270583
 
User avatar
javajox
newbie
Topic Author
Posts: 44
Joined: Fri Aug 23, 2013 9:32 pm

Re: How to obtain the list of route marks programmatically

Mon Jan 01, 2018 12:09 pm

Have a look at this post: using some of these commands you could build an array with all marks: viewtopic.php?f=9&t=53157&p=374555#p270583
sebastia, Thank you Sir, from the source which you've gave me, I was able to build this code :
:global retrieveAllRouteMarks do={
   :local currentMark;\
   :local allMarks [:toarray ""];\
   :foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes] do={\
      :set currentMark ([/ip route get $int routing-mark]);\ 
      if ([:len $currentMark] > 0) do={\
          :set allMarks [($allMarks, $currentMark)];
      }\    
   };\
  :return $allMarks;\	
};

Who is online

Users browsing this forum: No registered users and 26 guests