Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Author Rajeev S
- #Date 24 Aug 2011
- #Program to update IP address with no-ip
- import os #for system and popen
- import urllib #for urlopen
- t=os.system("ifconfig ppp0") #checking status of the system;wheteher online or not
- os.system("clear")
- if t==256: #exit if offline
- print "You are not connected to the internet!Connect and restart terminal to link website!"
- exit()
- else: #else read output of ifconfig ppp0
- ifconfig_ppp0=os.popen("ifconfig ppp0")
- ifconfig_ppp0=ifconfig_ppp0.read().split()
- for i in ifconfig_ppp0: #extract IP address (string that starts with addr)
- if i.startswith('addr'):
- ip=i[5:]
- break
- url="http://username:[email protected]/nic/update? hostname=mytest.testdomain.com&myip="+ip
- handle=urllib.urlopen(url).read() #fetch url
- if handle.startswith("good") or handle.startswith("nochg"):
- print "\t\tIP updated!Website is now on air!!!"
Advertisement
Add Comment
Please, Sign In to add comment