Checking for something before adding it

Hi All

I need to send a script to some units ( they pick it up each reboot) to amend the walled garden but I dont want to run the command if the exception is already added to the node.

The script is :

/ip hotspot walled-garden
add dst-host=www.wifiportal.co.uk
add dst-host=www.candengo.co.uk
add dst-host=www.apple.com
add dst-host=www.paypal.com method=""
add dst-host=www.paypalobjects.com
add dst-host=paypal.112.2O7.net
add dst-host=*.paypal.com
add dst-host=*.paypalobjects.com
add dst-host=*.akamaiedge.net

Im rubbish with scripting , how would I structure a line to only add the entry if its not already present?

Many thanks

Using the L7 script as an example, this works:

:if ([:len [/ip hotspot walled-garden find comment=www.apple.com]] > 0) do={ /log info "Entry already in walled garden" } else={ /ip hotspot walled-garden add dst-host=www.apple.com type=bypassed comment=www.apple.com }

Any better way?

That is the way I do it. Excel is your friend in these instances, place the URLs in a column then use excel formulas to create your command line for each instance and use that as your script.

/ip hotspot walled-garden {
    :local gardenList (\
          "www.wifiportal.co.uk"\
        , "www.candengo.co.uk"\
        , "www.apple.com"\
        , "www.paypal.com"\
        , "www.paypalobjects.com"\
        , "paypal.112.2O7.net"\
        , "*.paypal.com"\
        , "*.paypalobjects.com"\
        , "*.akamaiedge.net")
    :foreach i in $gardenList do={
        :if ([:len [find dst-host=$i]] = 0) do={
            add dst-host=$i
        }
    }
}