Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SCRIPT : VIEWS DEVICES LIKE A TREE

Status
Not open for further replies.

fabisu

MIS
Feb 10, 2012
2
0
0
FR
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

 
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)
 
maybe this will be usefull:

From:

$ ./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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top