Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Mar 2003 23:13:06 -0800 (PST)
From:      Viktor Lazlo <viktorlazlo@telus.net>
To:        Michael Collette <metrol@metrol.net>
Cc:        FreeBSD Mailing Lists <freebsd-questions@FreeBSD.ORG>
Subject:   Re: identifying my network address
Message-ID:  <20030309222546.K20073-100000@a3ij25fvy80j.bc.hsia.telus.net>
In-Reply-To: <200303092130.22748.metrol@metrol.net>

next in thread | previous in thread | raw e-mail | index | archive | help


On Sun, 9 Mar 2003, Michael Collette wrote:

> It's ugly.  It won't work if you multiple NICs.  It may just work for what you
> need just the same.
>
> echo `ifconfig | grep broadcast | cut -d" " -f2`":0.0"
>
> This takes the output of ifconfig and parses it just a wee bit with grep and
> cut.  I use something very similar to this in a script that changes my
> network settings for my laptop on the fly.

All you need to do to deal with multiple NICs is specify which interface
you want to poll.  Awk can also combine the actions of both grep and cut
in the example into a single process:

echo `ifconfig xl0 | awk '/broadcast/ { print $2":0.0" }'`

Cheers,

Viktor



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030309222546.K20073-100000>