User Tools

Site Tools


python:simple_dyndns_updater

Syntax: dyndns-update.py <user> <password> <host> [ip]

import sys,os,re
import urllib,socket
 
def update(user,password,host,ip):
        url = "http://%s:%s@members.dyndns.org/nic/update?hostname=%s&myip=%s" % (user,password,host,ip)
        return urllib.urlopen(url).read()
 
def local_ip():
        return socket.gethostbyname(socket.gethostname())
 
if len(sys.argv) < 4:
        print "Syntax: %s <user> <password> <host> [ip]" % sys.argv[0]
        sys.exit(1)
 
(user,password,host) = sys.argv[1:4]
if len(sys.argv) >= 5:
        ip = sys.argv[4]
else:
        ip = local_ip()
 
print "Updating %s to %s" % (host,ip)
print "Result: %s" % update(user,password,host,ip)
python/simple_dyndns_updater.txt · Last modified: 2012/08/15 13:54 by tkbletsc