Last active
January 9, 2019 20:32
-
-
Save JhonatanHern/fb17865da0da88213ffea33ea54ba304 to your computer and use it in GitHub Desktop.
My current ISP (Movistar) has a really bad system that crashes the connection every 5 or 10 minutes, my solution is this python script that pings google and restarts the connection when the ping fails.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import time | |
def checkConnection (): | |
return os.system("ping -c 1 google.com") == 0 | |
def connect(): | |
os.system("nmcli con up 'Movistar Default'") | |
while(True): | |
time.sleep(3) | |
if not checkConnection() : | |
print "connection trouble detected, restarting..." | |
connect() | |
time.sleep(15) | |
else: | |
print "connected" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment