Community discussions

MikroTik App
 
bonnecomm
newbie
Topic Author
Posts: 38
Joined: Sat May 30, 2009 8:29 am

How to determine if a setting is available

Tue Jul 06, 2021 6:14 am

This shouldn't be complicated but I'm not sure how to do this.
I'm writing a script that reconfigures a variety of 5-port routers to how we actually use them, which is nothing like the default configuration. I want one part of the script to work like this:
IF ether3 has poe-out available,
set poe-out on ether3 to forced-on.
ELSE IF ether5 has poe-out available,
set poe-out on ether5 to forced-on.
END IF
The problem is, I don't know how to tell if the poe-out setting is there. It's there on an RB750UP but not on an RB750. I want to do this without looking up the model number so the script will run properly on any and all 5-port models, not just the ones I know.

Thx
 
joegoldman
Forum Veteran
Forum Veteran
Posts: 766
Joined: Mon May 27, 2013 2:05 am

Re: How to determine if a setting is available

Tue Jul 06, 2021 6:44 am

Depending on the devices you need to support, you could always base it on /system routerboard model - from which you can pre-program on what to do for that model. This could be a bit more tedious if you are supporting a LARGE amount if different models but if its between 2 or 3 then its not bad.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to determine if a setting is available

Tue Jul 06, 2021 8:41 pm

If model contain "i" is poe capable on last ethernet
if model contain "0P" or "UP" is capable to poe from 2 to 5
if model contain "8P" is capable to poe from 1 to 8
if model contain "16P" is capable to poe from 1 to 16
if model contain "24P" is capable to poe from 1 to 24
if model contain "48P" is capable to poe from 1 to 48
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to determine if a setting is available

Wed Jul 07, 2021 4:00 am

This check if "poe" section are present or not, and if is present give number of interfaces with poe, if only one, print the name of the interface
:global poepresent false
:global interfaces 0
:global interfacename ""
:execute {/interface ethernet poe;:set poepresent true}
:delay 1s
:if ($poepresent) do={
            :set interfaces [:len [/interface ethernet poe find]]
            :put "Are present $interfaces PoE Interfaces"
            :if ($interfaces = 1) do={
                :set interfacename [/interface ethernet poe get [find] name]
                :put "The name of the only interface present is: $interfacename"
            }
    } else={:put "PoE not present"}

Who is online

Users browsing this forum: No registered users and 19 guests