Okay, this thread is long dead, but this is for pratsgl:
The original poster was looking for a way to resolve a hostname to an ip address.
Your script works great for getting the LOCAL ip address!
Did you know that you can do all of that parsing in awk, without using grep and sed? Try something like this to consolidate those 4 commands down to just 2:
ifconfig eth0|awk '/inet addr/ {split ($2,A,":"); print A[2]}'