Choosing an array with a variable

I am trying to create an auto-provisioning script that uses the MAC Address of ether1 to identify the router and automatically set some basic settings. This would be followed by a 2nd generic script that would use the variables set in the first script to complete the configuration/provisioning.

Ideally, this could be in a single multi-dimensional array, but I’d be OK with using an array per router as seen below:

#Arrays for each router (there would be 60+ more lines below)
:global “00:0C:AA:XX:XX:01” {“HostName”=“MIKROTIK1” ; “IPAddress”=“10.201.0.1” ; “CIDRSubNet”=“/23”};
:global “00:0C:AB:XX:XX:02” {“HostName”=“MIKROTIK2” ; “IPAddress”=“10.201.2.1” ; “CIDRSubNet”=“/23”};
:global “00:0C:AC:XX:XX:03” {“HostName”=“MIKROTIK3” ; “IPAddress”=“10.201.4.1” ; “CIDRSubNet”=“/23”};

The issue I’m having is calling the array using a variable that contains the MAC Address of ether1. I’ve tried it many different ways, but here is the gist of what I’m trying to accomplish (using the individual arrays above):

#Get the MAC address of ether1-gateway, then add a $ to the front for calling the Keys/Values from the Array
:global Array (“$” . [/interface ethernet get ether1-gateway mac-address]);
#Using :typeof, this creates a string

#Set variables for Host, IP and Subnet (CIDR) using the values pulled out of the array
:global Host ($Array->“HostName”);
:global IP ($Array->“IPAddress”);
:global SubNet (“$Array”->“CIDRSubNet”);

I’ve tried many different flavors of this with no luck. Oddly enough, if you used this syntax ($“00:0C:29:XX:XX:XX”) in a :foreach loop, it called in the keys and values in the array. See below:

:foreach k,v in=($“00:0C:AA:XX:XX:01”) do= {
:if ($k = “HostName” ) do={ :global Host $v }
:if ($k = “IPAddress” ) do={ :global IP $v }
:if ($k = “CIDRSubnet” ) do={ :global SubNet $v }
};

Has anyone ever successfully done this before? If so, any help will be greatly appreciated.

Thanks,

M

As a follow up, I did get the following results when trying different things using :execute to set the $Array variable.

To me, this looks like a bug: (<%% ( $00 (-> $:00:00:XX:XX:XX IP)) )

I also got this output when running /system script environment print after using :parse:

0 00:0C:AA:XX:XX:XX CIDRSubNet=/21;HostName=MKTK106;IPAddress=10.250.40.1
1 Array (code)

Does anyone know what “(code)” means?

Any thought would be greatly appreciated!

Thanks,

M