Page 1 of 1

Registration Count not working with use of variable reference

Posted: Thu Jan 05, 2023 9:24 pm
by O1DMBFan
Hello,
Tweaking one of my scripts to include total wireless registration count and running count as it loops through the entire list for action. Running into an issue where referencing the interface name as a variable returns no results, while explicitly referencing it returns the proper results. Can't seem to figure out why.
######The following DOES work:######
:local totalWirelessInt
#Set total wireless registrations
:set totalWirelessInt [/interface wireless registration-table print count-only where name=wlan1];
:log warning message= ("Total Wireless Clients of Radio: " . $totalWirelessInt)


######The following DOES NOT work:######
:local wirelessNAME;
:set wirelessNAME "wlan1";
:local totalWirelessInt
#Set total wireless registrations
:set totalWirelessInt [/interface wireless registration-table print count-only where name=$wirelessNAME];
:log warning message= ("Total Wireless Clients of Radio: " . $totalWirelessInt)
Thanks for your help!

Re: Registration Count not working with use of variable reference

Posted: Fri Jan 06, 2023 2:24 am
by rextended
You have omitted RouterOS version, as usual.

Work???
Sure???
On registration-table do not exist "name" field, but only "interface" for wlan1. ("radio-name" is the description, if provided, of the remote wlan)

Using correct syntax and logic... is advised...

correct code

# example 1
{
/interface wireless registration-table
:local totalWirelessInt [:len [find where interface="wlan1"]]
:log info "Total Wireless Clients of Radio: $totalWirelessInt"
}

# example 2
{
:local wirelessNAME "wlan1"
/interface wireless registration-table
:local totalWirelessInt [:len [find where interface=$wirelessNAME]]
:log info "Total Wireless Clients of $wirelessNAME: $totalWirelessInt"
}

Re: Registration Count not working with use of variable reference

Posted: Fri Jan 06, 2023 11:17 pm
by O1DMBFan
Thanks for your help, that's the advice I needed.

Cheers!