I have a Raspberry-Pi zero w and I want to connect it to the internet using a python script. I know the network ESSID and Password. Is there any python library that can do this? Is there any way I can do it via command line? If there is, I can use the subprocess library to execute that command. I have used the following command but it doesnt seem to work:
sudo iwconfig wlan0 essid NETWORKID key s:PASSWORD
It seems to run successfully without any errors but it doesn't connect the raspberry-pi to the internet.
I know I can use nmcli, but for some reason, I am avoiding it. Is there any other way I can connect to the internet using a python script/commandline?