Community discussions

 
sajjad2018
just joined
Topic Author
Posts: 11
Joined: Fri May 18, 2018 12:26 pm

Enlist hotspot user profiles

Sat Jun 08, 2019 9:09 pm

i have 100 of HOTSPOT USER PROFILES
I want to get names of USER PROFILES starting with letter "M" and Sotre in to an arrry.
I can not manage script for that.
PLZ Help
 
sajjad2018
just joined
Topic Author
Posts: 11
Joined: Fri May 18, 2018 12:26 pm

Re: Enlist hotspot user profiles

Mon Jun 10, 2019 9:33 am

Could Any one Plz Help Me//
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1234
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Enlist hotspot user profiles

Mon Jun 10, 2019 11:02 am

This will get all user starting with m or M inn to array list
:local list [:toarray [/ip hotspot user find where (name~"^m" || name~"^M")]]
To see if it get correct user try this:
:put [/ip hotspot user print where (name~"^m" || name~"^M")]
To test it out the code, copy and past this to cli
[
:local list [:toarray [/ip hotspot user find where (name~"^m" || name~"^M")]]
:put $list
]
It will NOT give you the name, but the ID of the line with the name in that you can use later in the script.
So result would be some like this:
*2;*3;*5
So I have three user that begins with M
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
sajjad2018
just joined
Topic Author
Posts: 11
Joined: Fri May 18, 2018 12:26 pm

Re: Enlist hotspot user profiles

Tue Jun 11, 2019 3:24 pm

Thank You Very Much For Your Help.
I was Needed user Profile Names The script was on USER List ...But Very Helpful., due to explaination.

I had tried a little, its working, but
if You please to Minimize this code,
{
:local list [:toarray [/ip hotspot user profile find (name~"^d" || name~"^D")]]

	:local nameList;
        :foreach u in=$list do={  
        :set nameList ($nameList, [/ip hotspot user profile get $u name]);
	 }
:put $nameList

}
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1234
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Enlist hotspot user profiles

Wed Jun 12, 2019 6:02 pm

You did miss where
[
:local list [/ip hotspot user profile find  where name~"^[dD]"]
:local nameList;
:foreach u in=$list do={ 
	:set nameList ($nameList, [/ip hotspot user profile get $u name])
}
:put $nameList
]
PS you can not use regex (?i) to search with case sensitive off. MT if your read this, please implement full regex.
But you can use [dD] to say it should be either d or D.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 16 guests