Realize the WiFi disconnection automatically, the principle is to use Python to monitor whether the network is disconnected, if the disconnection will restart the network service. Next to everyone to share the implementation of code, need to refer to the friend
1.Python code autowifi.py, placed in the/HOME/PI directory:
#!/usr/bin/pythonimportos, Time whiletrue: if ' 192 ' not in Os.popen (' ifconfig | grep 192 '). Read (): print ' \n**** * * WiFi is down, restart ... ******\n ' os.system (' sudo/etc/init.d/networking restart ') time.sleep (5*60) #5 Minutes
2.Shell script autowifi.sh, also placed in the/HOME/PI directory:
#!/bin/shpython/home/pi/autowifi.py &
3. Boot automatically start the above script: Execute the following command in the terminal window
Sudocp-f/home/pi/autowifi.sh/etc/init.d/sudochmod +x/etc/init.d/autowifi.shsudochown root:root/etc/init.d/ AUTOWIFI.SHSUDOUPDATE-RC.D autowifi.sh Default
The above is a small part of the python to introduce the realization of the Raspberry Pi WiFi disconnection automatically re-connected, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to everyone. Thank you very much for the support of the Scripting House website!