Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

devtree on AIX

by eddor1614 (Beadle)
on Nov 07, 2012 at 17:58 UTC ( #1002703=CUFP: print w/ replies, xml ) Need Help??

I've been looking for a command or script for AIX similar to lspci -t on Linux, a sort of Device tree

I didn't find it, although there are a few using shell script.

I've made a simple one using Perl, recursion and just one call to lsdev.

#!/usr/bin/perl use warnings; use strict; my $base = defined($ARGV[0]) ? $ARGV[0] : "ALL!"; if (defined($ARGV[0]) and $ARGV[0] eq "-h") { usage(); exit; } sub usage { print qq($/Usage:$/$/); print qq($0 [base] - "base is optional and defaults to sys0$/$/ +); print qq(This script builds a tree of devices$/$/); } my %devices = map { chomp; s/,$/,_/; split /,/,$_ } (`lsdev -F name,pa +rent`); sub children { my $parent = shift; my @lsdev; foreach (keys %devices) { push @lsdev, $_ if $devices{$_} eq $parent; } return @lsdev; } sub graph { my $step = shift; my @lista = @_; foreach my $i (@lista) { print "|", " " x $step,"|-- ",$i,$/; graph($step+3,children($i)); } } if ($base eq "ALL!") { graph(0,children("_")); } else { graph(0,$base); }

Comment on devtree on AIX
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://1002703]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-10-23 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (123 votes), past polls