Using Find in a Script

Hi Scripting guru’s

Im populating the /interface wireless connect-list using a text file which is working great. However, if i run the script a second time, it creates duplicates in the connect-list.

Im not sure of the best way to avoid this ? Im thinking its to use the /find option to see if the mac address is already in the connect-list and skip the command if it is. However, i just cant get the format right.

Could someone shed any light on how to structure the command to check for the existance of a mac address in connect list ?

Many thanks

:if ([:len [/interface wireless connect-list find where mac-address=$macaddress]]>0) do={
:log info "Existing mac found $macaddress"
} else={
/interface wireless connect-list add mac-address=$macaddress interface=wlan1 connect=yes
}

This uses the variable $macaddress when checking if there’s a matching existing listing. If there is it prints the log entry noting this, if not then it adds a new entry with the settings specified and the mac-address listed in variable $macaddress.

Hope this helps :slight_smile: