@williankevenis
[…]
:global ("eth" . $iface . "_name") $name
:global ("eth" . $iface . "_mac") $mac
:global ("eth" . $iface . "_comment") $comment
:global ("eth" . $iface . "_running") $running
:global ("eth" . $iface . "_disabled") $disabled
[…]
If assuming your code works, you would get something like:
eth*8_name = ether1
eth*8_mac = 00:11:22:.....
.....
eth*12_name = ether5
eth*12_mac = 00:11:22:.....
.....
eth*1_name = sfp1
eth*1_mac = 00:11:22:.....
eth*2_name = sfp2
eth*2_mac = 00:11:22:.....
Is what you want???
And, for hypothesys, you can achieve that, how you know on successive point what were the variables called?
It makes no sense, if you want to know the MAC of the ether1, go read it directly, instead of creating these variables in a cumbersome way,
which you then don't know later in the scripts what they are called...
Better that you explain exactly what you want to achieve in the end, so that I and the others can help you.
On meantime waiting some more precise info for you, take this....
:global ifarray [:toarray ""]
/interface ethernet
:foreach iface in=[find] do={
:set ($ifarray->"ether$iface_name" ) [get $iface name ]
:set ($ifarray->"ether$iface_mac" ) [get $iface mac-address]
:set ($ifarray->"ether$iface_comment" ) [get $iface comment ]
:set ($ifarray->"ether$iface_running" ) [get $iface running ]
:set ($ifarray->"ether$iface_disabled") [get $iface disabled ]
}
:foreach name,value in=$ifarray do={:put "$name = $value"}