A strange bug in firmware 7.16.1: netwatch and variable $ip
Posted: Tue Oct 22, 2024 9:48 am
I noticed a strange bug in version 7.16.1 of the script. I will demonstrate it in the following example::
The task of the script is to add a host with the address, for example, 8.8.8.8, to netwatch, if it has not been added before.
If I assign an IP address to the $ip domain, then the script will not find this netwatch element anyway.
If I assign the same ip to a variable with a different name, for example HostIP, then the script works fine.
The script must be executed twice. The first time he will not find the netwatch element 8.8.8.8 . and the second time he must definitely find it
Here's how it runs on the version RB4011iGS+ 7.15.3 (stable) EVERYTHING IS CORRECT HERE
Here's how it runs on the version RB951Ui-2HnD 7.16.1 (stable) THERE IS A BUG HERE with the use of a variable called $ip
Code: Select all
:local ip 8.8.8.8;
:local HostIP 8.8.8.8;
/tool netwatch print stats;
:if ([:typeof $ip]="ip" && [:len [/tool netwatch find host=$ip comment="ping"]]=0 ) do={
if ([:typeof $HostIP]="ip" && [:len [/tool netwatch find host=$HostIP comment="ping"]]=0 ) do={
put "not found \$ip $ip and not found \$HostIP $HostIP. Adding netwatch to $HostIP";
/tool netwatch add host=$HostIP comment="ping" interval=60 timeout=1000ms
} else={
:put "not Found \$ip $ip , but Found \$HostIP $HostIP. WHY?????? Nothing to do";
}
} else={
:put "Found IP $ip . Nothing to do";
}
/tool netwatch print stats;
If I assign an IP address to the $ip domain, then the script will not find this netwatch element anyway.
If I assign the same ip to a variable with a different name, for example HostIP, then the script works fine.
The script must be executed twice. The first time he will not find the netwatch element 8.8.8.8 . and the second time he must definitely find it
Here's how it runs on the version RB4011iGS+ 7.15.3 (stable) EVERYTHING IS CORRECT HERE
Code: Select all
[admin@Mik4011] > sys scr ru tesn
Flags: X - disabled
not found $ip 8.8.8.8 and not found $HostIP 8.8.8.8. Adding netwatch to 8.8.8.8
Flags: X - disabled
0 ;;; ping
type=simple host=8.8.8.8 timeout=1s interval=1m status=unknown
[admin@Mik4011] > sys scr ru tesn
Flags: X - disabled
0 ;;; ping
type=simple host=8.8.8.8 timeout=1s interval=1m status=up since=2024-10-22 09:17:50 done-tests=1 failed-tests=0
Found IP 8.8.8.8 . Nothing to do
Flags: X - disabled
0 ;;; ping
type=simple host=8.8.8.8 timeout=1s interval=1m status=up since=2024-10-22 09:17:50 done-tests=1 failed-tests=0
[admin@Mik4011] >
Here's how it runs on the version RB951Ui-2HnD 7.16.1 (stable) THERE IS A BUG HERE with the use of a variable called $ip
Code: Select all
vadim@M61] > sys scr ru testn
Flags: X - disabled
not found $ip 8.8.8.8 and not found $HostIP 8.8.8.8. Adding netwatch to 8.8.8.8
Flags: X - disabled
0 ;;; ping
type=simple host=8.8.8.8 timeout=1s interval=1m status=unknown
[admin@M61] > sys scr ru testn
Flags: X - disabled
0 ;;; ping
type=simple host=8.8.8.8 timeout=1s interval=1m status=up since=2024-10-22 09:20:00 done-tests=1 failed-tests=0
not Found $ip 8.8.8.8 , but Found $HostIP 8.8.8.8. WHY?????? Nothing to do
Flags: X - disabled
0 ;;; ping
type=simple host=8.8.8.8 timeout=1s interval=1m status=up since=2024-10-22 09:20:00 done-tests=1 failed-tests=0