[plug] getting IP address in a shell script
chris
choypoy at bigpond.net.au
Tue Jul 30 18:15:56 WST 2002
something like
ifconfig ppp0 | grep inet | cut -d : -f 2 | cut -d \ -f 1
be careful with spaces, theres 2 spaces towards the end (after the last
\ and before the -f 1 etc)
this is something I picked up from some dynamic DNS script that I
shamelessly used a lot .
ppp0 can be any interface eth0 etc - you can stick others in here as
well
something like
MY_IP = `ifconfig ppp0 | grep inet | cut -d : -f 2 | cut -d \ -f 1`
hope that helps.. )
On Tue, 2002-07-30 at 17:57, Craig Ringer wrote:
> Hi all
> 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.
>
> --
> Craig Ringer
> GPG Key Fingerprint: AF1C ABFE 7E64 E9C8 FC27 C16E D3CE CDC0 0E93 380D
> -- if it ain't broke, add features 'till it is. (or:)
> while (! broken) { features ++ ; broken = isBroken(features) }
>
>
More information about the plug
mailing list