Friday, December 3, 2010

Displaying The IP Address of my linux computer

I'm building a robot that has a computer monitor as it's head (literally), but no keyboard or mouse to support a UI. I'd like to connect to it by using the IP address for general operation, but I need to know what it is. What to do?

I've seen many posts about people looking for how to display the ip address on the desktop. My case is similar. My solution was to write a shell script that was added to the startup programs (under Settings >> Sessions & Startup) that looks like this:


#/bin/bash

w=$(ifconfig eth0 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}')
wl=$(ifconfig wlan0 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}')
msg=$(echo "Wired :" $w "\n" "Wireless :" $wl)

zenity --info --text="$msg" &



On startup, a message box is displayed that indicates the IP address.

No comments: