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.
#encoding=utf8 #I hate everything that is not in UTF8 import urllib2, subprocess, string #your host php file address host = 'http://your-page.org/robot.php' #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 urllib2.urlopen(host+'?'+question+'='+q)
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.
#encoding=utf8 #I hate everything that is not in UTF8 import urllib2, os #your host php file address host = 'http://your-page.org/robot.php' #command to run. telnet or ssh probably command = 'telnet ' #open url u = urllib2.urlopen(host) #read ip and execute the command os.system(command+u.read())