boat73 has asked for the wisdom of the Perl Monks concerning the following question:

Oh wise ones. Does anyone know of a way to get the slot number that a NIC is in via perl? I am hoping to do this cross platform but will take what I can get.

Replies are listed 'Best First'.
Re: get NIC slot
by dynamo (Chaplain) on May 12, 2005 at 17:18 UTC
    Hmm. I doubt that you can do this in a cross-platform manner. There's no guarantee that a NIC is even in a 'slot' (I'm assuming you mean PCI-X slots, but it could be anything - that's really my point.) The best way to do that, IMHO, is to have a system-dependent script get called to locate the NIC (sorry, can't help you on the details of _how_), then convert slot number you get back into an english description (so later you can have it cover NICs built-in on motherboards, or over firewire, or in PC card slots, etc.. On unix systems, I expect you can get useful info by poking around in the /dev hierarchy (or using modules that do it for you). Good luck.
Re: get NIC slot
by ikegami (Patriarch) on May 12, 2005 at 18:18 UTC
Re: get NIC slot
by traveler (Parson) on May 12, 2005 at 19:16 UTC
    For Linux, lspci tells you what is in each slot. The manual for that program (man lspci) discuses /proc/pci that actually holds the info. The library it uses is supposedly "cross platform".

    I don't know if there is a Cygwin version.

    HTH, --traveler

Re: get NIC slot
by traveler (Parson) on May 15, 2005 at 16:52 UTC
    ethtool appears to do what you want. Maybe you can check the code and port the useful stuff to Perl.