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

Is there a perl module (or perl script way) to detect the hardware being used by a linux system ?

I'd like a way of knowing what hardware exists in the PC without relying on the user to know.

Thanks.

Replies are listed 'Best First'.
Re: linux hardware detection using perl
by zentara (Cardinal) on May 16, 2006 at 18:59 UTC
    It's pretty much all in /proc, but you need to know how to interpret it. You may also need to run the script as root, to get all system info.

    This isn't Perl, but it does a nice job. See lshw It contains some hardware database info, to assist you in interpreting whats in /proc. Maybe you could use the info and do it with Perl.


    I'm not really a human, but I play one on earth. flash japh
Re: linux hardware detection using perl
by samtregar (Abbot) on May 16, 2006 at 18:40 UTC
    I don't know of a Perl module, but you can try parsing the output of 'dmesg' and/or 'lspci' depending on what you're trying to detect. Alternately, if you're looking for a specific device you might be able to probe /proc or /dev for the appropriate interface.

    -sam

Re: linux hardware detection using perl
by tirwhan (Abbot) on May 18, 2006 at 16:09 UTC

    This kind of stuff is what HAL is supposed to be for. I'm not aware of a Perl module to interface with it at the moment though. Maybe you could write one ;-)?


    All dogma is stupid.
Re: linux hardware detection using perl
by Mr. Muskrat (Canon) on May 18, 2006 at 15:26 UTC
    I've done it before by combining several approaches until I had all the information I wanted. I parsed dmesg and scanned the /proc virtual filesystem. I was working on a Red Hat system so I also went through /etc/sysconfig/hwconf (Fedora Core should have this too I suppose).