[plug] getting IP address in a shell script

Leon Brooks leon at brooks.fdns.net
Tue Jul 30 19:03:26 WST 2002


On Tue, 30 Jul 2002 18:07, Colin Muller wrote:
> On Tue, Jul 30, 2002 at 05:57:46PM +0800, Craig Ringer wrote:
>> Any ideas about a non-ugly (ie pref not /sbin/ifconfig eth0 | awk ... )
>> method of getting the local machine's IP address into a variable in a
>> shell script? There's probably something obvious I'm missing but apropos
>> and google haven't helped on a quick glance.

> Maybe this:
> variable=`hostname -i`

Only if you can guarantee that the primary hostname refers to the interface 
you want.

Cheers; Leon



More information about the plug mailing list