NPDedyukhin wrote: ↑
Tue Jan 07, 2020 6:38 am
Now my task is to edit the file “wpa_supplicant.conf” with the help of a python script in such a way as to enter into it the data that the user entered.
Does anyone know how to do this?
Sounds like a great little project for learning python
Use a temporary file while experimenting so as not to mess up the real one.
Learn in small steps:-
Read in the source file.
Parse the source file contents.
Print the values to the screen so you know its been read and parsed OK.
Read in and write out the temporary wpa_supplicant.conf file (check its unchanged with cmp).
Write a second copy of the original wpa file as a backup (wpa_supplicant.conf.save)
Next insert the users data into it before writing.
Finally, add a check that its not there already to avoid duplicates.
Note that you could just open the wpa_supplicant.conf file for append and simply write the new entry to it.
The trouble with that is if you ran the program twice you get duplicate entries.