Page 1 of 1

How to check including port to bridge?

Posted: Tue Jul 09, 2013 2:48 pm
by greek
Hello.

How i can check is eth port into bridge already or not? In script.

Re: How to check including port to bridge?

Posted: Wed Jul 10, 2013 9:09 am
by c0d3rSh3ll
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"}}

Re: How to check including port to bridge?

Posted: Wed Jul 10, 2013 4:21 pm
by greek
Thank you! I'll try to test this script!

Re: How to check including port to bridge?

Posted: Thu Jul 11, 2013 12:57 am
by krakenant
: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.

Re: How to check including port to bridge?

Posted: Thu Jul 11, 2013 10:29 am
by greek
: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={} ?

Re: How to check including port to bridge?

Posted: Thu Jul 11, 2013 4:21 pm
by krakenant
: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={}

Re: How to check including port to bridge?

Posted: Thu Jul 11, 2013 4:58 pm
by greek
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 ?

Re: How to check including port to bridge?

Posted: Fri Jul 12, 2013 4:13 pm
by miks69
How can I check the pptp interface is there in bridge or not?

Re: How to check including port to bridge?

Posted: Fri Jul 12, 2013 4:31 pm
by greek
miks69, have your interface static name or not?

Re: How to check including port to bridge?

Posted: Fri Jul 12, 2013 4:34 pm
by miks69
Yes, I have. But above script is not showing it...

Re: How to check including port to bridge?

Posted: Fri Jul 12, 2013 5:49 pm
by greek
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] > 

Re: How to check including port to bridge?

Posted: Fri Jul 12, 2013 6:47 pm
by miks69
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"}

Re: How to check including port to bridge?

Posted: Mon Jul 15, 2013 5:21 pm
by greek
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"}