User Tools

Site Tools


python:simple_dyndns_updater
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


python:simple_dyndns_updater [2012/08/15 13:54] (current) – created tkbletsc
Line 1: Line 1:
 +Syntax: dyndns-update.py <user> <password> <host> [ip]
  
 +<code=python>
 +
 +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)
 +</code>
python/simple_dyndns_updater.txt · Last modified: 2012/08/15 13:54 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki