Community discussions

MikroTik App
 
O1DMBFan
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Fri Dec 05, 2008 11:08 pm

Registration Count not working with use of variable reference

Thu Jan 05, 2023 9:24 pm

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!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Registration Count not working with use of variable reference

Fri Jan 06, 2023 2:24 am

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"
}
 
O1DMBFan
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Fri Dec 05, 2008 11:08 pm

Re: Registration Count not working with use of variable reference

Fri Jan 06, 2023 11:17 pm

Thanks for your help, that's the advice I needed.

Cheers!

Who is online

Users browsing this forum: Ahrefs [Bot] and 17 guests