Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Apr 2003 15:35:02 -0700
From:      Tom Smith <tom@openadventures.org>
To:        DJ Boris <dj_boris@mail.ru>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: extract IP address and feed it into a command
Message-ID:  <3EADAC96.6020601@openadventures.org>
References:  <01de01c30dd1$5c5d4c10$6300a8c0@fmelectro.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
This is taken from a Linux firewall script I use to determine a Dynamic 
IP address. In this case, $IFCONFIG, $EXTIF, and $AWK are defined as 
variables. For reference, IFCONFIG=/sbin/ifconfig, EXTIF=eth0, AWK=/bin/awk.

EXTIP="`$IFCONFIG $EXTIF | $AWK 
$EXTIF/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`"

I didn't write this script so I don't fully understand what it's doing 
but maybe it'll lead you in the right direction.

DJ Boris wrote:

>hi there,
>
>I am running fBSD 4.7 release.
>
>I need to extract my IP address which is dynamically assigned by my ISP and
>feed it into a serialmail command
>
>"maildirsmtp ~alias/pppdir alias-ppp- 1.2.3.4 `hostname` "
>
>which is executed from my ppp.linkup.
>
>I have to replace hostname with my dynamic IP.
>
>I know that my IP always starts with zzz.zzz and if I run
>
>"ifconfig | grep zzz.zzz"
>
>I get
>
>inet zzz.zzz.xxx.xxx --> yyy.yyy.yyy.yyy netmask nnnnnnnnnn
>
>Is there a command or something else that I can use in order to get only the
>IP starting with zzz.zzz up to the first space and how do I feed it into the
>above command?
>
>thanx
>dj boris
>
>
>_______________________________________________
>freebsd-questions@freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
>  
>





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3EADAC96.6020601>