[CentralOH] SheevaPlug - Python app right out of the box!

Jon Miller jonebird at gmail.com
Thu Apr 1 16:12:29 CEST 2010

I felt bad for supplying a shell version... another trick you can do
is to use the 'socket' module. If you happen to have a host which you
can connect to on the network, then this trick might be good for you.
In my example, I'll connect to a  fictious server named 'jumpbox' on
port 22:

import socket
s1 = socket.socket()
s.connect(('jumpbox', 22))
print 'My IP is %s' % s.getsockname()[0]

-- Jon Miller

On Thu, Apr 1, 2010 at 9:36 AM, Jon Miller <jonebird at gmail.com> wrote:
> This is what I do to determine my frontend IP:
>  INTERFACE=$(/sbin/ip route list default | sed -n '/^default /s/.*
> dev \([a-z0-9]*\) $/\1/p' | head -1)
>  /sbin/ip addr show dev $INTERFACE primary | sed -n '/inet /s/.*inet
> \([^ ]*\) .*$/\1/p' | sed 's|/24||g'
> -- Jon
> On Thu, Apr 1, 2010 at 9:03 AM, Mark Erbaugh <mark at microenh.com> wrote:
>> Has anyone in the COhPy messed with a SheevaPlug? This is a "plug computer" that comes preloaded with a version of Ubuntu 9.04 and, more importantly, Python 2.5 is installed. I have a small (but useful) web-based app written using webpy. I simply copied the files to a USB memory stick. Once I mounted the memory stick on the SheevaPlug, I issued the command 'python main.py' and my app was off an running. Pretty cool!
>> I have a question related to my webpy app.  Is there some python code for determining the IP address on which it is listening?  When the webpy app runs, it always displays  I end up having to use ifconfig to get the IP address.
>> Mark
>> _______________________________________________
>> CentralOH mailing list
>> CentralOH at python.org
>> http://mail.python.org/mailman/listinfo/centraloh

More information about the CentralOH mailing list