How to read ifconfig in FreeBSD..Help plss

Brooks Davis brooks at one-eyed-alien.net
Tue Nov 14 18:12:22 UTC 2006


On Tue, Nov 14, 2006 at 10:00:18AM -0800, subba wrote:
> 
> Hi,
> 
> 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 help me
> in reading the IP and others from ifconfig...
> I am trying to use
> char *cmd[] = { "ifconfig","-a",(char *)0 }
> execv("/sbin/ifconfig,cmd);
> 
> If there is a better solution to have the console set up, I would love to
> know it...I'd appreciate your help.

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.

-- Brooks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20061114/f7f9bc2d/attachment.pgp


More information about the freebsd-rc mailing list