Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Mar 2002 09:08:37 -0600
From:      Ben Kadish <Ben.Kadish@happcontrols.com>
To:        freebsd-questions@freebsd.org
Subject:   Determining local IP(s)
Message-ID:  <5.1.0.14.0.20020329085816.065885d8@mail.happcontrols.com>

next in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello All,

I'm writing a Perl script for which I'm trying to determine if a certain IP 
is bound to a given NIC. I was trying to do it by regex matching the output 
of ifconfig as follows:

$ifconfig = `ifconfig`;
if ($ifconfig =~ m/. $IPADDRESS ./) {
	execute this code;
}

I got to thinking that this was grossly inefficient, and since it wasn't 
working anyway, I started wondering if there is a more efficient way to do 
this in Perl with some system functions I didn't know about. I looked 
through the sysctl variables and environment variables to no avail. Any ideas?

- ----------
Ben Kadish		Ben.Kadish@happcontrols.com
Network Analyst
Happ Controls, Inc.

GnuPG Public Key 86EEC8F6 available from http://wwwkeys.us.pgp.net
- ----------

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (MingW32)
Comment: For info see http://www.gnupg.org

iD8DBQE8pINgqpnDV4buyPYRAhWPAKCBkCkFTsf/CFyK59BbEbzcBytzFQCg2cDe
bahrMhHGtKlz57ZL/bX0Xcw=
=noVb
-----END PGP SIGNATURE-----


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?5.1.0.14.0.20020329085816.065885d8>