Dave Donovan wrote:
Thanks for the caveats Ian. I thought of that when I put in the ETH0
but I forgot to mention it when I posted. I was kinda sleepy.
I forgot to put the warning banner: Caution - Ugly Hack
I wasn't happy using ifconfig but when I went around looking for a
command that just spit back an IP address, I realized that it's not
really as simple as one might think. Which IP address? Which
interface? For instance, I resolved hostname but all I got back was
127.0.0.1. That's not very helpful.
I did find an interesting application of the diaplan app CURL
somewhere (maybe in the Wiki) that uses http://checkip.dyndns.org to
return your external IP as the world sees you. It was actually
easier, and it seems maybe more reliable than trying to return the
address of a local interface.
I wasn't able to run either of your suggested commands successfully.
I'm not sure why. Here's where I confess that I borrowed that awk
syntax from someplace not really knowing _why_ it worked. But still,
the command you posted returns:
192.168.xxx.yyy Bcast
and if I remove the -F and 'addr' I get:
addr:192.168.xxx.yyy
Oops, you're right, sorry. On Linux you're better off w/ the original.
Just more proof in general that it's an "ugly hack", as you say.