Click to See Complete Forum and Search --> : IP address from sh?


Spacecake
04-21-2001, 11:41 AM
I was just writing a simple shell script, and after ages of searching through man pages, i still can't find a way to find the IP address from a sh script (i use a dynamic IP).

Is there a variable with it in? Or a program that spits it out?

If not, how would i write a simple C proggy that would spit it out? (just give me the names of the h files with the required net functions and i can probly figure it out from there)

Thanks :)

EscapeCharacter
04-21-2001, 11:48 AM
export EXTIP=`ifconfig $EXTIF | awk '/inet addr/ { gsub(".*:", "", $2) ; print $2 }'`
echo $EXTIP

where $EXTIF equal your external interface

[ 21 April 2001: Message edited by: EscapeCharacter ]