Community discussions

MikroTik App
 
arcsin
just joined
Topic Author
Posts: 4
Joined: Wed Nov 21, 2018 1:30 pm

Find specific SSID using Scan function

Mon Sep 06, 2021 4:35 pm

Hello,

Is it possible to use Scan function to find specific (previously known) SSID? For example, I would like to go around my neighborhood and inspect if there is SSID with name "Test_Network", but in a way that I do not need to look through all the other SSID's shown up in the terminal/winbox window (basic Scan functionality).
Long story short - is there a possibility to use SSID as filter parameter for Scan function?

Thank you in advance.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Find specific SSID using Scan function

Mon Sep 06, 2021 7:21 pm

is there a possibility to use SSID as filter parameter for Scan function?
On WinBox:
No.

But you can do other things not directly related to use Scan funciton on WinBox
Last edited by rextended on Wed Sep 08, 2021 4:24 pm, edited 4 times in total.
 
User avatar
antonsb
MikroTik Support
MikroTik Support
Posts: 385
Joined: Sun Jul 24, 2016 3:12 pm
Location: Riga, Latvia

Re: Find specific SSID using Scan function  [SOLVED]

Wed Sep 08, 2021 4:12 pm

yes, you can in multiple different ways:
1) if you can connect to network - you can check interface status (running or not) and based on that write a script
2) if you can't connect you can check log messages when interface tries to connect, but fails
3) You can run scan and check if ssid is present - for example:
foreach i in=([interface/wireless/scan wlan1 duration=5 as-value]) do={if (($i->"ssid")="Test_Network") do={:put $i}}
 
arcsin
just joined
Topic Author
Posts: 4
Joined: Wed Nov 21, 2018 1:30 pm

Re: Find specific SSID using Scan function

Fri Sep 10, 2021 3:06 pm

Thank you, antonsb.
Looks like you know exactly the solution I am looking for, I just need some guidance because I am not familiar with MT scripts.
First things first - I cannot connect to the network, so solution #1 is not appropriate.
Solution #2 - looks like this is what I am looking for, thank you! At first I got some weird messages in logs (using connection list) but it turned out that if you specify SSID in connection list, SSID field must be clear in interface configuration menu. If it is not too much to ask, for me it would be very useful if you can add some comments to the script you wrote in solution #3.
Solution #3 - this looks like the solution, but unfortunately I am not familiar with MT scripts. Could you please explain step-by-step what does this script do? It would be extremely helpful.
 
User avatar
antonsb
MikroTik Support
MikroTik Support
Posts: 385
Joined: Sun Jul 24, 2016 3:12 pm
Location: Riga, Latvia

Re: Find specific SSID using Scan function

Fri Sep 10, 2021 4:27 pm

sure, sorry i gave v7 compatible code v6 will look like this
foreach i in=([/interface wireless scan wlan1 duration=5 as-value]) do={if (($i->"ssid")="Test_Network") do={:put $i}}
so what does this do:
/interface wireless scan wlan1 duration=5 as-value
does scan for 5 seconds and saves results in arrays of results
foreach i in=... do={}
goes through every element of this array
if (($i->"ssid")="Test_Network") 
checks if ssid in each array results matches your desired SSID
do={:put $i}}
in this case just returns all values for ssid if that ssid was found
like this:
.id=*7;address=4C:5E:0C:5D:D3:B1;channel=5180/20/an/P(11dBm);nf=-109;radio-name=4C
5E0C5DD3B1;routeros-version=6.46.6;sig=-85;snr=24;ssid=sssss 
this pretty much depends what you want to do. for example if your MikroTik router is equipped with beeper you can run something like this continuously:
while (true) do={foreach i in=([/interface wireless scan wlan1 duration=5 as-value]) do={if (($i->"ssid")="Test_Network") do={:put $i; :for i from=1 to=3 step=1 do={:beep frequency=550 length=494ms;:delay 494ms;:beep frequency=400 length=494ms;:delay 494ms;}}}}
you can also post data in external DB using fetch etc...
 
arcsin
just joined
Topic Author
Posts: 4
Joined: Wed Nov 21, 2018 1:30 pm

Re: Find specific SSID using Scan function

Mon Sep 13, 2021 5:47 pm

antonsb, thank you very much!
Now I understand how the script/command should work, unfortunately in v6.48 ROS does not allow to recall Scan results as internal ID numbers (using as-value).
[reinis@Mikrotik cAP ac] > foreach i in=([/interface wireless scan wlan1 duration=5 as-value]) do={if (($i->"ssid")="Test_Network") do={:put $i}}
expected end of command (line 1 column 58)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Find specific SSID using Scan function

Mon Sep 13, 2021 6:50 pm

Is not casual I say "No." on #2 post

On 6.47.10, and up, you can save scan to file and read results for furter analisys, the as-value is added from 7.?
{
/interface wireless scan wlan1 duration=5 save-file=tempscan.txt
:local filecontent [/file get [/file find where name="tempscan.txt"] contents]
:put $filecontent
}
And for beginner do such ting is really hard.
 
kwinz
just joined
Posts: 5
Joined: Fri Oct 11, 2019 7:27 pm

Re: Find specific SSID using Scan function

Wed Sep 14, 2022 4:49 pm

It's really unintuitive that there is no way for me to filter scan search results by an SSID from the command line (SSH)?

  • Apparently there is no way to pipe to a utility like grep.
  • The command doesn't have a "where" argument.
  • And "as-value" seems to have been removed? Is there another way to put the output from the scan command in a structured way into variables ala https://wiki.mikrotik.com/wiki/Manual:Scripting ?

Is there at least a way to make a named pipe instead of a real file for the "save-file=" argument?

Or am I misunderstanding something completely?

Who is online

Users browsing this forum: No registered users and 37 guests