On Wed, 08 Feb 2006 15:24:53 -0600, Bit Twister wrote:
> On 8 Feb 2006 13:15:06 -0800, (E-Mail Removed) wrote:
>> Hi ,
>>
>> What is the best way to determine the IP address of a machine ? I have
>> to parse the IP and assign it to a variable using a script .
>
> ping -c 1 $(hosthame)
> ifconfig
Here's my script for getting the "inside" and
the "outside" IP addy's for the machines on my SOHO
LAN.
:
|#!/bin/sh
|echo -n ' PC ip: ' && /sbin/ifconfig | grep 'inet addr:' | \
| grep -v '127.0.0.' | cut -d: -f2 | cut -d' ' -f1
|echo -n 'Net ip: ' && \
| wget -O-
http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null
It's not original by me. I pieced it together from the contents of many
other postings I slogged through via groups.google.com.
HTH, but YMMV
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
*** Killfiling google posts: <http//jonz.net/ng.htm>