Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm aware that I can use ethtool eth0|eth1|eth2 to check the existence of a NIC. But I wonder where the files are on the machine that contain information of an existing interface, as I need to use the Ruby language to check for available NICs.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

There is /proc/net/dev, but I am sure there is an actual Ruby API to do this correctly.

see http://curioushq.blogspot.com/2011/04/listing-all-network-interfacesdevices.html

share|improve this answer
    
Great! Thanks a lot. –  Terry Li Jul 20 '11 at 17:16
add comment

Call ethtool as an external process and parse its output. If you want information related to IP settings, call ifconfig in preference to ethtool, because ifconfig is always present whereas ethtool will be present only if the system administrator has installed it. An alternative to ifconfig is ip, but it's not always present and its output is only marginally easier to parse than ifconfig's, so use ifconfig if it provides the right output for you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.