On Fri, Apr 28, 2000 at 01:39:30PM -0700, Dan Browning wrote:
> In a shell script, how do I assign a varialbe the current dynamic ip address
> for a given interface?  What about current default gateway?
This works in bash. You might have to change the $(foobar) to `foobar`
to make it work in csh or sh. Don't remmeber right now.

CUURENTIP=$(ifconfig | grep --after-context=1 "$INTERFACE" | sed -n 's/.*addr:\([^ 
]*\).*/\1/p')

CURRENTDEFAULTROUTE=$(route -n| sed  -n 's/^0\.0\.0\.0 *\([^ ]*\).*/\1/p')

> 
> Thanks
you're welcome

There's a way to do the first one without grep, but it doesn't come to mind
immeadiately. Sorry for the waste of a process.

sed forever!

greg
-- 
military intelligence. portable C.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs

Reply via email to