myip.org - dns client
skip at mojam.com
Thu Nov 9 14:08:31 CET 2000
Anders> There are some clients at the myip.org site, but they are
Anders> written in perl and my computer is a perl free zone!
I'll probably make a mistake transcribing the perl code (and since I don't
use myip.org I can't really test it anyway), but here's a first cut that
should get you close.
import urllib, os, re
# modify to suit your environment and myIP account info
interface = "ppp0"
userid = "myiploginname"
pwd = "myippassword"
hostname = "spamneggs.myip.org"
recordtype = "A"
# end of modification section
ipdata = os.popen("ifconfig " + interface)
ipaddress = None
for line in ipdata.readlines():
mat = re.search(r"addr:(\d+\.\d+\.\d+\.\d+)")
if mat is not None:
ipaddress = mat.group(1)
if ipaddress is None:
raise ValueError, "couldn't read my IP address!"
f = urllib.urlopen("http://www.myip.org/cgi-bin/Update.py?"
Skip Montanaro (skip at mojam.com)
Support the Mojam.com Affiliates Program: http://www.mojam.com/affl/
More information about the Python-list