If statment in function

Good Morning everyone.

Goal: use an specific OID in a function according to Device.Type in dude functions.

Problem: I can pull the [device.type] correctly but when I check it in a if statement i get “Parse Failed”. So I know my code is probably not correct.

My Code: if(device_property(“Type”)) = “Mimosa” ,oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”)

This basically should be a function that checks if a device.type (My custom type I have setup in dude) is equal to set string value. If they match then return a OID value.

Any help PLEASE, I have lookded everywhere with no luck.

I have also tried to see if string_size wont work either but it does not.

What I tried: if(string_size(device_property(“Type”))) = string_size(“Mimosa”),oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),“”)

if(device_property(“Type”)) = “Mimosa” ,oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”)
=>
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “” )

if(string_size(device_property(“Type”))) = string_size(“Mimosa”),oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),“”)
=>
if ( string_size(device_property(“Type”)) = string_size(“Mimosa”), oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “” )

Hi Rextended

your code doesnt seem to work either.

Rex that last one WORKED

not tested code

It just for put on evidence the wrong place of the “)”

Im going to try and see if it works on all my others and I will revert back with my findings.

Thank you SO much!

Rextended,

For my Mikrotik devices I get error " Expected end of command (Line 1 Column 14)

My Code: if ( device_property(“Type”) = “MikroTik”, ros_command(“:put /system resource get board-name”), “”)

My nested IF seems to be wrong. I cant find the syntax for this :c

Code:

if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”), “”),
if ( device_property(“Type”) = “MikroTik”, ros_command(“:put /system resource get board-name”), “”),
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “”),
if ( device_property(“Type”) = “BDcom”, “”,
“Fix ME”,)

Updated code:

if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”), “”,“”)
if ( device_property(“Type”) = “MikroTik”, ros_command(“:put [/system resource get board-name]”), “”,“”)
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “”,“”)
if ( device_property(“Type”) = “BDcom”, “”, “”)

in the nested IF:

There is a problem with matching device.type…

If I used the mimosa OID line, it gets used for all devices no matter the if condition??/ im confused why it does this.

I have Also tried this:

if ( device_property(“Type”) = “MikroTik”, ros_command(“:put [/system resource get board-name]”), if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”), if ( device_property(“Type”) = “BDcom”, 0))))

Ok this code only pulls the 1st if statement but if it the condition does not match it does not fall to the else statement?

if ( device_property(“Type”) = “MikroTik”, ros_command(“:put [/system resource get board-name]”),
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),
if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”),
if ( device_property(“Type”) = “BDcom”, “”,“”))))

Hi,

I dont know why this if is still not working. ive tried so much.

Code:

if ( device_property(“Type”) = 0, ros_command(“:put [/system resource get board-name]”),
if ( device_property(“Type”) = 1, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),
if ( device_property(“Type”) = 2, oid(“2.840.10036.3.1.2.1.3.5”),“”)))
Screenshot 2023-10-03 133535.png

Bump of shame

So the IF function is bugged according to MikroTik support.

Need to see what work around I can get instead.