Linksys Router & Python

Tony C cappy2112 at gmail.com
Mon Nov 1 19:55:29 EST 2004


BRad

Here's a one-liner way of getting your IP address, but you'd need a
shell
account on a webserver to get it.
I made a python CGI script, and had it print the IP address of the
client as HTML.

import os
print os.environ["REMOTE_ADDR"]

I don't show the code to to format the output as HTML, but that's
rpretty straightforward.

However, this would still require you to have your computer on while
you're away, which isn't your goal. But at least you don't have to
login to your router to get the info.

You can accomplish the same thing by running a python script to
www.myipaddress.com, and scraping the screen.

These are just another ways of getting your IP address.
I copied this from a post on CLP, so I can't take credit for it.

Brad Tilley <bradtilley at gmail.com> wrote in message news:<cltjkt$4fi$1 at solaris.cc.vt.edu>...
> Probably a stupid question, but here goes:
> 
> Is there any way to get a scaled down version of Python onto a Linksys 
> Wireless router? Are there any projects out there that are doing this? 
> I've googled around a bit, but didn't find much. I want to keep the 
> router's software as it is, but I also would like to have some scripting 
> abilities on it as well (like email the router's IP addy every x hours), 
> etc.
> 
> I have scripts that run on my computers that do this sort of thing.
> 
> def url_open():
>      """ Function that gets and returns the IP addy
>      of my Linksys BEFW11S4 Wireless DSL router."""
>      import urllib, re
>      ip = re.compile ('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
>      f = urllib.urlopen("http://user:passwd@192.168.1.1/RouterStatus.htm")
>      data = f.read()
>      f.close()
>      routerip = ip.findall(data)
>      print routerip[0]
>      return routerip[0]
> 
> But, when I leave town for vacation, I don't like leaving a computer 
> running. If I could get the interpreter embedded in the device itself, 
> then that would solve the problem.
> 
> This is probably a shot in the dark, but I thought I'd ask.
> 
> Thanks,
> Brad



More information about the Python-list mailing list