I would like to save a file with the values discovered during the foreach loop below.
But, I’m having a hard time with appending values to the variable. I believe I need to use an array, but it’s beyond me at this time.
# Collect IP addresses
:foreach neighborID in=[/ip address find] do={
:local nb [/ip address get $neighborID]
:local id [:pick ("$nb"->".id") 1 99]
:foreach key,value in=$nb do={
:local newline [:find $value "\n"]
:if ([$newline]>0) do={
:set value [:pick $value 0 $newline]
}
:if ($key~"add") do={
:log info message="script=IP-ADDRESSES nid=$id value=$key=\"$value\""
:log info message="System IP Address $value"
:local tempipaddressvalue $value
:local ipaddressvalue "$tempipaddressvalue \n $value"
:local interimipaddressvalue [get tempaddressvalue contents]
:local newipaddressvalue "$interimipaddressvalue$value"
:local finalipaddressvalue
set $finalipaddressvalue contents=$newipaddresscontents
}
}
}
/file add name=finalipaddressvalues contents=$finalipaddressvalues
Help would be appreciated.