Robot automatic IP updater

So, I'm working on a robot project that is using BeagleBoard development board with Ubuntu 11 on it. It seems fun, although a bit slow for Gnome. So it would be nice to boot it in text mode (working on that) and use ssh or telnet to develop the code. So there started my problem. The board boots up and connects with local internet. Now I want to connect with it but I don't know the IP address. So I have to plug display and keyboard to my robot to get the IP address so I wouldn't have to plug the display and keyboard on it. Kind of self cancelling. So I made a script to help me.

First part is in Python, it gets robot's local IP address and sends it to a php file outside. This should go to start-up of client/robot/slave computer.

#I hate everything that is not in UTF8
import urllib2, subprocess, string

#your host php file address
host = ''
#secret question
question = 'i_am_the_robot'
#get my ip
q = subprocess.check_output(['ip','addr','show','wlan0'])
q = q[(string.find(q,'inet')+5):]
q = q[:string.find(q,'/')]
#do the magic

The second part is php file, that accepts the IP addresses if necessary and displays the last known IP address.

The third part is just for convenience. You could go to your webpage and copy the IP from there, but in case you are lazy like everybody, this python script will do it for you.

#I hate everything that is not in UTF8
import urllib2, os
#your host php file address
host = ''
#command to run. telnet or ssh probably
command = 'telnet '
#open url
u = urllib2.urlopen(host)
#read ip and execute the command
Posted on 2011-10-17, 09:48 By
1 comment Categories: Robotex

One thought on “Robot automatic IP updater

Leave a Reply

Your email address will not be published. Required fields are marked *