Hello,
I am trying to script the output of a configuration to make changes to it before setting it to the content of a file.
I am able to receive the value of each property but I am unable to get the property name - it always returns the first first character of the value.
I have based my script off of: http://forum.mikrotik.com/t/save-export-to-variable/36882/1
Thank you.
:global line
:global contents
:global findindex
:global property
:global value
/interface ethernet {
:set contents "/interface ethernet \n"
# Loop through ethernet interfaces
:foreach r in=[print detail as-value] do={
:set line ""
#Build array from properties and values
:foreach i in=[$r] do={
#debugging
:put $i
:set findindex [:find [:tostr $i] "="]
#property only returners the first character of value
:set property [:pick [:tostr $i] 0 $findindex]
#value is returned as expected
:set value [:pick [:tostr $i] ($findindex) [:len [:tostr $i]]]
:delay 2
}
}
:if ([:len $property] > 0 && [:len $value] > 0) do={
:set line ([:tostr $line] . $property . "=" . $value . " ")
}
}