Community discussions

 
djrainyman
just joined
Topic Author
Posts: 9
Joined: Sun Jun 09, 2013 9:54 am

How to create a loop to add bridge with pre-defined configuration?

Wed Dec 05, 2018 5:45 am

hi. i want to write a loop to create a bridge interface with defined name but not worked. where is problem?
#brnum is number of bridge that i want to create
:local brnum "2";
#brname is name of every bridge that i want defined from number 1 to brnum
:local brname1 "bridge-work";
:local brname2 "bridge-game";
#brcomm is comment of every bridge that i want defined from 1 to brnum
:local brcomm1 "work bridge";
:local brcomm2 " game bridge";
#now i want to write a loop
:for br from=1 to=($brnum) do={
/interface bridge;
add name=$brname$br comment=$brcomm$br arp=reply-only auto-mac=yes fast-forward=no mtu=1500}
second $ after first $ in $brname$br not accepted how to write this to mikrotik accept this and works without problem
 
User avatar
Steveocee
Forum Veteran
Forum Veteran
Posts: 900
Joined: Tue Jul 21, 2015 10:09 pm
Location: UK
Contact:

Re: How to create a loop to add bridge with pre-defined configuration?

Wed Dec 05, 2018 1:21 pm

Hello,

This shouldn't be too difficult to do, do you need the bridge names to be dynamic some how or just a set name and comment for each? Reading your script you've already made I don't see the need for scripting what could be a few lines of config though?
Steve "Steveocee" Carter
PC Gamer, Airsofter, MikroTik Nerd
My Website - My MikroTik Tutorials
 
djrainyman
just joined
Topic Author
Posts: 9
Joined: Sun Jun 09, 2013 9:54 am

Re: How to create a loop to add bridge with pre-defined configuration?

Wed Dec 05, 2018 1:35 pm

Hello,

This shouldn't be too difficult to do, do you need the bridge names to be dynamic some how or just a set name and comment for each? Reading your script you've already made I don't see the need for scripting what could be a few lines of config though?
hi steve thanks for your reply. I want to set name and comment for each and i want to write public configuration script that no need to write a command for creating every bridge.
what should i do to resolve a problem?
 
djrainyman
just joined
Topic Author
Posts: 9
Joined: Sun Jun 09, 2013 9:54 am

Re: How to create a loop to add bridge with pre-defined configuration?

Fri Dec 07, 2018 1:17 pm

No Way???! :( :( :(
my question is one section on many section of configuration script that i write.my purpose to writing this script is that no need to write many lines and define all environment on first lines and loop sections are linked and connected together
 
User avatar
eworm
Member Candidate
Member Candidate
Posts: 182
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: How to create a loop to add bridge with pre-defined configuration?

Wed Dec 12, 2018 10:12 pm

Try this:
add name=($brname . $br) comment=($brcomm . $br) ...
Manage RouterOS scripts and extend your devices' functionality: RouterOS Scripts

Who is online

Users browsing this forum: eworm and 6 guests