I’m new to scripting and I’m trying to write a script that makes the router notifying me whenever a new Wireless device is being connected or disconnected by making a beep sound. My script captures a view of registration-table and compares it with a new one which being taken periodically. I think there must be something wrong with my variables; because the “if” command only recognizes them as to be the same. Any help and ideas would be appreciated. Here’s my script:
{
:global first;
:set first [/interface wireless registration-table];
:while (true) do={
:delay 500ms;
:global second;
:set second [/interface wireless registration-table];
:if ([$first] = [$second]) do={} else={
:beep;
:global first ($first = $second);
}
}
}
Use:
[/interface wireless registration-table find]
and
:if ([:len $first] = [:len $second]) do={} else={\
and change that last global statement to
:set $first $second
and move :global second out of the loop.
Thank you for your reply. I tried this as below:
{
:global first;
:global second;
:set first [/interface wireless registration-table find];
:while (true) do={
:delay 500ms;
:set second [/interface wireless registration-table find];
:if ([:len $first] = [:len $second]) do={} else={
:beep;
:set $first $second;
}
}
}
Still not working though.
It works for me (tested with bridges to make it easier to control).
Yep, you’re right. I’ve just rebooted my router and it’s working! Thank you Sid5632.