|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Alex (axs
m-net.arbornet.org)Date: Mon Apr 08 2002 - 12:54:14 CDT
127.0.0.1
On Mon, 8 Apr 2002, Philipp Buehler wrote:
> On 05/04/2002, veins <veins
skreel.org> wrote Cc misc
openbsd.org:
> > IS_UP=`ifconfig tun0 | grep '<UP,'`;
> > if [ "${IS_UP}" != "" ]; then
> > MY_IP=`ifconfig tun0 | tail -1 | cut -d' ' -f2`;
> > echo "ip address: ${MY_IP}";
> > else
> > echo "interface is down.";
> > fi
>
> Bah.. people, know your tools.
> This one works (tested) on OpenBSD and Red Hat Linux:
> (wrote it once, where I need those checks for crossplattform scripts):
> BEGIN {num=0; FS=":[ \t]*|[ \t]+"}
> /^[a-z]/ { ifn[num] = $1 }
> /inet addr/ {ifa[num] = $4}
> /netmask/ { ifa[num-1] = $3}
> /UP/ {ifu[num]=1;num++}
> END { count=0
> while (count <= num) {
> if (ifu[count] ) print ifn[count] ":" ifa[count]
> count++
> }
> }
>
> Yes, that's awk ;) (I am pretty confident, this is [ng]awk specific).
> Just pipe ``ifconfig -a'' to it.
>
> ciao
> --
> Philipp Buehler, aka fips | sysfive.com GmbH | BOfH | NUCH | <double-p>
>
> #1: Break the clue barrier!
> #2: Already had buzzword confuseritis ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]