Community discussions

MikroTik App
 
User avatar
greek
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Thu Nov 04, 2010 11:37 pm
Location: Russia, 78rus

How to check including port to bridge?

Tue Jul 09, 2013 2:48 pm

Hello.

How i can check is eth port into bridge already or not? In script.
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 557
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: How to check including port to bridge?

Wed Jul 10, 2013 9:09 am

try this, change name1 for your interface.

ros code

foreach i in=[interface bridge port find] do={
local name1 wlan1
local name2 [interface bridge port get value-name=interface $i]
if ($name1 = $name2) do={ log error "interface $name1 is in a bridge"} \
else={log error "interface $name1 is not in a bridge"}}
 
User avatar
greek
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Thu Nov 04, 2010 11:37 pm
Location: Russia, 78rus

Re: How to check including port to bridge?

Wed Jul 10, 2013 4:21 pm

Thank you! I'll try to test this script!
 
krakenant
Member Candidate
Member Candidate
Posts: 135
Joined: Sat Feb 06, 2010 6:32 am

Re: How to check including port to bridge?

Thu Jul 11, 2013 12:57 am

:local INTNAME ether1
:put [/interface bridge port find where interface=$INTNAME]

Everything after the :put will return nothing if it isn't in a bridge or a unique identifier if it is in the bridge. You could also add disabled=no and bridge="bridge1" to specify if the port is disabled in the bridge port and specify which bridge it is on.
 
User avatar
greek
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Thu Nov 04, 2010 11:37 pm
Location: Russia, 78rus

Re: How to check including port to bridge?

Thu Jul 11, 2013 10:29 am

:local INTNAME ether1
:put [/interface bridge port find where interface=$INTNAME]
Thanks! How i can use into the scripr "empty answer" of this example?

if [/interface bridge port find where interface=$INTNAME] == "empty?" do={} else={} ?
 
krakenant
Member Candidate
Member Candidate
Posts: 135
Joined: Sat Feb 06, 2010 6:32 am

Re: How to check including port to bridge?

Thu Jul 11, 2013 4:21 pm

:if ([/interface bridge port find where interface=$INTNAME] = "") do={} else={}
Alternatively if you want it o do something if it isn't blank:
:if ([/interface bridge port find where interface=$INTNAME] != "") do={} else={}
 
User avatar
greek
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Thu Nov 04, 2010 11:37 pm
Location: Russia, 78rus

Re: How to check including port to bridge?

Thu Jul 11, 2013 4:58 pm

krakenant, Thanks a lot! It's Very usefull example for me!

ps: Maybe, can you help me in neighbor topic: http://forum.mikrotik.com/viewtopic.php?f=2&t=74534 ?
 
miks69
just joined
Posts: 7
Joined: Sun Jul 07, 2013 11:32 am

Re: How to check including port to bridge?

Fri Jul 12, 2013 4:13 pm

How can I check the pptp interface is there in bridge or not?
 
User avatar
greek
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Thu Nov 04, 2010 11:37 pm
Location: Russia, 78rus

Re: How to check including port to bridge?

Fri Jul 12, 2013 4:31 pm

miks69, have your interface static name or not?
 
miks69
just joined
Posts: 7
Joined: Sun Jul 07, 2013 11:32 am

Re: How to check including port to bridge?

Fri Jul 12, 2013 4:34 pm

Yes, I have. But above script is not showing it...
 
User avatar
greek
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Thu Nov 04, 2010 11:37 pm
Location: Russia, 78rus

Re: How to check including port to bridge?

Fri Jul 12, 2013 5:49 pm

Try:
[greek@RT] >  :if ([/interface bridge port get  number=[/interface bridge port find where point-to-point-port=yes  ] interface] = "work") do={:put "in_bridge"} else={:put "not_in_bridge"}
in_bridge
[greek@RT] > 
 
miks69
just joined
Posts: 7
Joined: Sun Jul 07, 2013 11:32 am

Re: How to check including port to bridge?

Fri Jul 12, 2013 6:47 pm

it seems something wrong in above script because I have an error "no such item":

:if ([/interface bridge port get number=[/interface bridge port find where point-to-point-port=yes] interface]="w
ork") do={:put "in bridge"} else={:put "not in bridge"}
 
User avatar
greek
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Thu Nov 04, 2010 11:37 pm
Location: Russia, 78rus

Re: How to check including port to bridge?

Mon Jul 15, 2013 5:21 pm

Very strange workaround, but it's work:

ros code

:if ([/interface bridge port find where point-to-point-port=yes] != "") 
    do={
          :if ([/interface bridge port get  number=[/interface bridge port find where point-to-point-port=yes  ] interface] = "work") 
             do={:put "in_bridge"} 
           } 
    else={:put "not_in_bridge"}

Who is online

Users browsing this forum: Bing [Bot], pe1chl and 73 guests