Page 2 of 2 First 12
  • Jump to page:
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Rep Power
    I didn't look at urllib2, but it seems to require knowledge of classes (which I am skechy on) to create a database of the password (with the HTTPPasswordMgr objects) and then open the http connection. If you would like to help it would be great though!


    Well I figured it out...
    Here is the program to get the external ip address of an linksys defsr41 v2 and then use ez-ipupdate to update the dynamic dns service

    import os
    import re
    from urllib2 import urlopen, unquote, Request
    import base64
    #various things needed
    linksysurl = ""
    linksysuserpass = "username:password"
    updateusername = "username:password"
    updatehost = "the name of the host you wish to update"
    def ExternalIP():
    	status = getlinksys(linksysurl)          #Get status page and parse out externalip address
    	ipline = re.sub('<.*?>|&nbsp','',status) #parse out html tags and &nbsp
    	ipline = re.sub(';','\n',ipline)         #change semicolons to new lines in order re.findall to work
    	ip = re.findall ('IP Address:.*',ipline) #parses out ip[0] = internal IP and ip[1] = external IP
    	ipiwant = re.sub ('[^0-9\.]','',ip[1])
    	#Check if the oldip = newip and if so return "error code"
    	file = open("/tmp/oldip",'r')
    	oldip = (
    	if ipiwant == oldip:
    		return 1
    	#write newip to file for later checking
    	file = open("/tmp/oldip",'w')
    	return ipiwant
    def UpdateIPAddress():
    	externalip = ExternalIP()
    	if externalip == 1:
    		return 1
    	#Uses unix program ez-ipupdate to update ip
    	os.system ("ez-ipupdate --address " + externalip + " --user "+updateusername+
    	" --service-type dyndns --host " + updatehost)
    def getlinksys(url):
    	#get the webpage and return it
    	req = Request(url)
    	# for some reason must base64 encode the username and password
    	req.add_header('Authorization', 'Basic ' + userpass64)
    	return urlopen(req).read()
    Thanks for the help!
    Last edited by coscarart; September 24th, 2003 at 03:09 PM.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo