Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 2006 14:05:06 -0600
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        subba <subba@t8design.com>
Cc:        freebsd-rc@freebsd.org
Subject:   Re: How to read ifconfig in FreeBSD..Help plss
Message-ID:  <20061114200506.GB51226@lor.one-eyed-alien.net>
In-Reply-To: <7344729.post@talk.nabble.com>
References:  <7342892.post@talk.nabble.com> <20061114181204.GA51226@lor.one-eyed-alien.net> <7344729.post@talk.nabble.com>

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

--A6N2fC+uXW/VQSAv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

[Please don't top-post on FreeBSD mailing lists.]

On Tue, Nov 14, 2006 at 11:36:12AM -0800, subba wrote:
>=20
>=20
> Thanks Brooks,
>=20
> I am not sure about 'to read the source and copy the parts into your
> application'. Can you please elaborate?. When you said reading the source,
> does it mean that pipe the 'ifconfig' to a file and read that file ... li=
ke
>  % ifconfig > somefile.txt
> and read somefile.txt and get the ip, netmask and others.?
> If this is the case, how can i pipe(C program) when the user logs in...i.e
> when the user logs in, console menu should be displayed with current
> IP,netmask etc. I am not sure if i am in the right direction. I'd appreci=
ate
> your help.

Since you are writing a C program, just do what ifconfig does
rather than trying to parse it's output.  I.e. copy what you need from
src/sbin/ifconfig/*.c (retaining appropriate license and copyright
statements).

-- Brooks

>=20
> Thanks,
> Subba
>=20
>=20
> Brooks Davis wrote:
> >=20
> > On Tue, Nov 14, 2006 at 10:00:18AM -0800, subba wrote:
> >>=20
> >> Hi,
> >>=20
> >> I have to write console menu set up, where user can change the IP ,
> >> netmask,gateway settings etc.
> >> To Start with i need to read 'ifconfig' and get the 'ip' and 'netmask'
> >> and
> >> store it in a file and read the file to get the output. Can somebody h=
elp
> >> me
> >> in reading the IP and others from ifconfig...
> >> I am trying to use
> >> char *cmd[] =3D { "ifconfig","-a",(char *)0 }
> >> execv("/sbin/ifconfig,cmd);
> >>=20
> >> If there is a better solution to have the console set up, I would love=
 to
> >> know it...I'd appreciate your help.
> >=20
> > The better solution by far would be to read the source and copy the
> > parts you need into your application rather than trying to parse
> > ifconfig output in C.
> >=20
> > -- Brooks
> >=20
> > =20
> >=20
>=20
> --=20
> View this message in context: http://www.nabble.com/How-to-read-ifconfig-=
in-FreeBSD..Help-plss-tf2631184.html#a7344729
> Sent from the freebsd-rc mailing list archive at Nabble.com.
>=20
> _______________________________________________
> freebsd-rc@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-rc
> To unsubscribe, send any mail to "freebsd-rc-unsubscribe@freebsd.org"
>=20

--A6N2fC+uXW/VQSAv
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFWiFxXY6L6fI4GtQRAnPRAJ0TIKtjgbBDsqoFH9aVAmzbxDDi1wCg1V8A
D8rml0aIKlXyHP9VUN9xQh8=
=crc2
-----END PGP SIGNATURE-----

--A6N2fC+uXW/VQSAv--



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