User avatar
NPDedyukhin
Posts: 28
Joined: Fri Sep 20, 2019 3:23 am
Location: RU

WiFi Scanner

Wed Oct 09, 2019 7:20 pm

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:
Respectfully,
Nikita Dedyukhin

gkaiseril
Posts: 664
Joined: Mon Aug 08, 2016 9:27 pm
Location: Chicago, IL

Re: WiFi Scanner

Wed Oct 09, 2019 7:31 pm

f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.

User avatar
NPDedyukhin
Posts: 28
Joined: Fri Sep 20, 2019 3:23 am
Location: RU

Re: WiFi Scanner

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
Respectfully,
Nikita Dedyukhin

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: WiFi Scanner

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
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
NPDedyukhin
Posts: 28
Joined: Fri Sep 20, 2019 3:23 am
Location: RU

Re: WiFi Scanner

Wed Oct 09, 2019 7:48 pm

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". :|
Respectfully,
Nikita Dedyukhin

User avatar
peppy.player
Posts: 201
Joined: Mon Mar 07, 2016 6:10 am

Re: WiFi Scanner

Fri Oct 11, 2019 3:14 pm

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

User avatar
neilgl
Posts: 1197
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: WiFi Scanner

Fri Oct 11, 2019 5:30 pm

And is iwlist the old command and the newer iw command has more features?

Code: Select all

sudo iw wlan0 scan | egrep 'SSID|signal'

Return to “Python”