INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Jobs from Indeed

SCRIPT : VIEWS DEVICES LIKE A TREE

SCRIPT : VIEWS DEVICES LIKE A TREE

(OP)
Hi all,

I would like to know if somebody already did a script to make a "Tree view" of the devices with Parents and Childs with the basic commands lsdev and odmget ?

Thanks,

Fabisu

 

RE: SCRIPT : VIEWS DEVICES LIKE A TREE

(OP)
Actually it's look like this :

#!/usr/bin/ksh

# Name Specifies the device logical
echo " "
echo "### Devices in the system and their characteristics ###"
lsdev -l $1

# LIST CHILDS FROM THE SELECTED DEVICE
echo " "
echo "### LIST CHILDS FROM THE DEVICE $1 ###"
lsdev -l $1 | awk '{ print "lsdev | grep " $3}' | sh | sort -n

# LIST PARENTS FROM THE SELECTED DEVICE
echo " "
echo "### PARENT DEVICE FOR $1 ###"
lsdev -l $1 -F parent

# LIST PARENTS FROM THE SUB-DEVICE SELECTED
echo " "
a=$(lsdev -l $1 -F parent)
echo "### PARENT DEVICE FOR $a ###"
lsdev -l $(lsdev -l $1 -F parent) -F parent

# LIST ALL THE CHILD DEVICES CONNECTED TO THE DEVICE
echo " "
echo "### ALL THE CHILD DEVICES CONNECTED TO DEVICE $a ###"
lsdev -p $(lsdev -l $1 -F parent)

# LIST ALL THE CHILD DEVICES CONNECTED TO THE DEVICE
echo " "
b=$(lsdev -l $(lsdev -l $1 -F parent) -F parent)
echo "### ALL THE CHILD DEVICES CONNECTED TO DEVICE $b ###"
lsdev -p $(lsdev -l $(lsdev -l $1 -F parent) -F parent)

RE: SCRIPT : VIEWS DEVICES LIKE A TREE

maybe this will be usefull:

From:
http://www.tek-tips.com/viewthread.cfm?qid=1535579

$ ./devlist2 hdisk0
hdisk0
scsi0
sisscsia0
pci5
pci0
sysplanar0
sys0


CODE

#!/bin/ksh
dev=$1
echo $dev
devstat=$(lsdev -C -F status -l ${dev} 2>/dev/null)
if [[ $devstat != Available && $devstat != Defined ]]
then
 echo "$dev undefined"
else
 while [[ $dev != sys0 ]]
 do
  dev=$(lsdev -Cl $dev -F parent)
  echo $dev
 done
fi

 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close