Wednesday, January 2, 2013

How to find out the parent device using script in AIX?

How to find out the parent device using script in AIX?

Using the below script we can find out the parent device (path of the device) of any device. Create the file  with the below script and provide the execute permission.


#!/usr/bin/ksh
f_lsdev ()
{
echo $1
lsdev -l $1 -F parent 2>/dev/null | read y
f_lsdev $y
}
set -e
f_lsdev $1 | xargs echo
#


touch lsdevpath
# vi lsdevpath   -----> (paste the above script on the file)
# chmod +x lsdevpath

Here we run the script to find out the path (parent device) of the hdisk3


./parent_device hdisk3
hdisk3   scsi2    sisscsia1    pci3    pci1    sysplanar0    sys0
t#

From the above output, we can find out the parent device (path of the device)of the hdisk3.

hdisk3 --parent_device--> scsi2 --parent_device-->sisscsia1--parent_device-->pci3 --parent_device-->psi1 --parent_device-->sysplanar0--parent_device-->sys0