Page 1 of 1

WiFi Scanner

Posted: Wed Oct 09, 2019 7:20 pm
by NPDedyukhin
Good afternoon! :P

When we connect the Raspberry Pi to a WiFi network, we can enter a command in the console to see a list of available networks:

iwlist wlan0 scan

What should a python script look like that will do the same? :roll:

Re: WiFi Scanner

Posted: Wed Oct 09, 2019 7:31 pm
by gkaiseril

Re: WiFi Scanner

Posted: Wed Oct 09, 2019 7:36 pm
by NPDedyukhin
gkaiseril wrote:
Wed Oct 09, 2019 7:31 pm
See Executing Shell Commands with Python
Not found, error 404

Re: WiFi Scanner

Posted: Wed Oct 09, 2019 7:41 pm
by pcmanbob
NPDedyukhin wrote:
Wed Oct 09, 2019 7:36 pm
gkaiseril wrote:
Wed Oct 09, 2019 7:31 pm
See Executing Shell Commands with Python
Not found, error 404
Simple error extra character added to end of address

Try : https://linuxhandbook.com/execute-shell-command-python

Re: WiFi Scanner

Posted: Wed Oct 09, 2019 7:48 pm
by NPDedyukhin
pcmanbob wrote:
Wed Oct 09, 2019 7:41 pm
NPDedyukhin wrote:
Wed Oct 09, 2019 7:36 pm
gkaiseril wrote:
Wed Oct 09, 2019 7:31 pm
See Executing Shell Commands with Python
Not found, error 404
Simple error extra character added to end of address

Try : https://linuxhandbook.com/execute-shell-command-python
Thanks for the tip.

I figured out how to do it.

The code is as follows:

Code: Select all

import os 
myCmd = 'iwlist wlan0 scan | grep "ESSID"' 
os.system (myCmd)
But now the problem is that if this script is run without using "sudo" - it gives information only about my network.

Other networks can only be seen if you start it manually using "sudo". :|

Re: WiFi Scanner

Posted: Fri Oct 11, 2019 3:14 pm
by peppy.player
What's the problem starting the script with 'sudo' ? Here is the example from Peppy player:
https://github.com/project-owner/Peppy/ ... il.py#L292

Re: WiFi Scanner

Posted: Fri Oct 11, 2019 5:30 pm
by neilgl
And is iwlist the old command and the newer iw command has more features?

Code: Select all

sudo iw wlan0 scan | egrep 'SSID|signal'