Check IP script died after update - maybe

I have a dynamic public IP from my ISP. For years I have had a script that checks the address and sends some E-Mails if the IP has changed. Most of the script was right off the Wiki. My IP seldom changes, but when it would change, the script always worked. However it appears that when I updated the RB4011iGS+ router from 6.49.8 to 6.49.15 last week, the script died. I looked at the release forum posts for every update in between and did not see anything that would relate to this. I fully admit that I am NOT a scripting expert by any means. I added a few info log entries to try to determine where it was dying and narrowed it down to one line that is directly out of the Wiki. If I run the script, the log entry “Line 2” gets logged, but “Line 3” does not. Yes, E10_Fiber_Internet is the correct name for the Interface, and I have also tried it as [ find default-name=ether10 ] with the same result.

add dont-require-permissions=no name="Check Frontier IP" owner=redacted \
    policy=read,write,policy,test source=":log info \"Start IP check script\";\
    \r\
    \n:global CurrentFOIP;\r\
    \n:log info \"Line 2\";\r\
    \n:local NewIP [/ip address get [find interface=\"E10_Fiber_Internet\"] ad\
    dress];\r\
    \n:log info \"line 3\";\r\
    \n:local OldIP;\r\
    \n:local CurrentTime\r\
    \n:local CurrentDate\r\
    \n:log info \"line 4, \$OldIP \$CurrentTime\";\r\
    \n:set CurrentDate ([:pick [/system clock get date] 0 11]);\r\
    \n:set CurrentTime ([:pick [/system clock get time] 0 8]);\r\
    \n:log info \"Current IP is \$CurrentFOIP\";\r\
    \n:if (\$NewIP != \$CurrentFOIP) do={\r\
    \n    :set OldIP \$CurrentFOIP;\r\
    \n    :set CurrentFOIP \$NewIP;\r\
    \n    :log info \"Fiber IP address of \$OldIP changed to new IP of \$NewIP\
    \";\r\
    \n\r\
    \n  /tool e-mail send to=\"redacted@gmail.com\" subject=\"Frontier IP add\
    ress change\" body=\"\$CurrentDate at \$CurrentTime - Frontier internet IP\
    \_address change.\\n \\n Old IP address was:  \$OldIP \\n New IP address i\
    s:  \$NewIP \\n If Old IP is blank, most likely a router startup. \\n\";\r\
    \n\r\
    }

The script continues with a couple more E-Mails.
Any ideas?

If the interface have more than one IP address, all crash…

you must correct from
[get [find interface=“E10_Fiber_Internet”] address]
to
[get ([find where interface=“E10_Fiber_Internet”]->0) address]
(and hope that the first address is right…)

Wiki or not, the script have some errors… some bigger than others…

Ding! Ding! Ding!!

Totally forgot that I had in fact give the WAN interface a static 192.168.100.0/24 address because that is the local management address for the ONT. Simple solution will be to remove that address…
Always look to what the tech did last - or in this case two steps ago…

Thank you.

not tested, but the solution for not lost ONT access is…
[get ([find where interface=“E10_Fiber_Internet” and !(address in 192.168.100.0/24) ]->0) address]

Thank you very much. Sometimes it’s the obvious. I deleted the extra IP and the script worked correctly so you were right on the money.
I will give your second suggestion a try. I understand exactly what it is all doing with one exception. Can you explain what the meaning or purpose of the “->0” is near the end?

->0 select the first item in the array.
the find retrieve two or more items, if the interface have more than one IP

with ([find]->0) on the script you are sure that return or none or only one value (the first).