What I need: Connect to different wifi network on archlinux by calling python script.
What I am doing: Executing the following statements from python:
wpa_passphrase "MySSID" "MyPass"> /etc/wpa_supplicant/profile.conf
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/profile.conf
dhcpd wlan0
It works only for the first attempt. When it is executed the second time, it says dhcpd is already on. I dont know how to switch to another network.
I have also tried wpa_cli and again, dont know how to switch to another network.
Please suggest some fix or alternatives (uncomplicated)
Edit /etc/wpa_supplicant.conf
Complete the file to make it look like that (replacing wifi_name and wifi_key by their real values of course).
and
Then save and exit
The wifi network is now configured, we must now tell that we want to connect to it using this configuration file.
If your interface isn't named wlan0 then replace wlan0 by the real name of your interface. We must now request an IP adress.
If everything gone well you now see several lines containing some IP addresses and the command ping should work.