0

Wpa_cli command requires you to know in advance if a network is open or secured. I'm developing a script using wpa_cli and I just want it to connects to network whether it is open or secured , obviously if secured it should ask for password otherwise it should just connect.

How can I check if a network is open or secured so that scripts runs wpa_cli accordingly?

I just want a behavior like android phone, if a network is open it just connects to it, if it is secured it asks for password.

1 Answers1

1

You can tell from the probe response what security settings a network is using.

In wpa_cli you'll need to do a scan and parse the results to find the SSID you want to connect to, and there it will tell you the security settings:

wpa_cli scan

Then to see the results of the scan:

wpa_cli scan_results

There is also another command that is not related to wpa_cli. From a shell:

iwlist interfaceID scan

Where interfaceID is your wireless adapter (e.g. wlan0).

This gives you scan results but with much more detail. Again this can be used to deduce the security settings of a network.

artm
  • 17,291
  • 6
  • 38
  • 54
Dominic Gifford
  • 816
  • 7
  • 7