Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Parse linux /proc/pci?

by traveler (Parson)
on Nov 03, 2003 at 19:49 UTC ( [id://304225] : perlquestion . print w/replies, xml ) Need Help??

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

Hating to reinvent the wheel, I have searched SuperSearch and CPAN, but to no avail. I need to parse /proc/pci on a series of linux systems to try to discover their hardware configurations. Does anyone have a module to do this, or am I on my own?


Replies are listed 'Best First'.
Re: Parse linux /proc/pci?
by Anonymous Monk on Nov 03, 2003 at 21:52 UTC
    You should parse the output of the lspci program, instead. /proc/pci is in the process of being deprecated. lspci also offers a -m option, which is designed to make it simpler for scripts to parse.
      I should have noted that I am using mandrake 9.2: it does not have lspci.


        That's weird, you should have it in some package (maybe pciutils or a similar name).


Re: Parse linux /proc/pci?
by batkins (Chaplain) on Nov 03, 2003 at 20:27 UTC
    You're probably on your own. It's probably not too difficult - gratuitous globb'ing and regexen should get you where you need to go. If you get something working, feel free to post it to CPAN.

    The computer can't tell you the emotional story. It can give you the exact mathematical design, but what's missing is the eyebrows. - Frank Zappa
Re: Parse linux /proc/pci?
by rob_au (Abbot) on Nov 03, 2003 at 22:59 UTC
    The module that you want to take a look at is Proc::ProcessTable - I have posted a review of this module on this site previously here.


    perl -le "print+unpack'N',pack'B32','00000000000000000000001010001011'"

      I must be missing something. How do you use Proc::ProcessTable to retrieve the information contained in /proc/pci (or the detail contained in lspci)? I haven't checked the README, but the documentation at CPAN makes no mention of this.

      If things get any worse, I'll have to ask you to stop helping me.