From owner-freebsd-rc@FreeBSD.ORG Tue Nov 14 20:44:25 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D85A916A4EB for ; Tue, 14 Nov 2006 20:44:25 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C19E43E28 for ; Tue, 14 Nov 2006 20:38:20 +0000 (GMT) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net ([12.207.12.9]) by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP id <20061114203443m9100el8mje>; Tue, 14 Nov 2006 20:34:44 +0000 Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.13.8/8.13.8) with ESMTP id kAEK5qko053034; Tue, 14 Nov 2006 14:06:23 -0600 (CST) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.13.8/8.13.8/Submit) id kAEK5L22053030; Tue, 14 Nov 2006 14:05:21 -0600 (CST) (envelope-from brooks) Date: Tue, 14 Nov 2006 14:05:06 -0600 From: Brooks Davis To: subba Message-ID: <20061114200506.GB51226@lor.one-eyed-alien.net> References: <7342892.post@talk.nabble.com> <20061114181204.GA51226@lor.one-eyed-alien.net> <7344729.post@talk.nabble.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="A6N2fC+uXW/VQSAv" Content-Disposition: inline In-Reply-To: <7344729.post@talk.nabble.com> User-Agent: Mutt/1.5.11 Cc: freebsd-rc@freebsd.org Subject: Re: How to read ifconfig in FreeBSD..Help plss X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2006 20:44:26 -0000 --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--