dispaly vg's and pv's?

hi

i need to write a script,

the script display's list of volume groups followed by physical volumes with in volume group and at the same time the script should display the pvid of physical volume.

what i need is, how to read the line by line from the files...

the below is my script..

echo "List of Volume Groups and Physical Volume:"
while read xxxxxx (the xxxx should read from file reportvg.out)
do
lsvg -p xxxxxx > reportpv.out (the xxxxx is vg anme)
while read xxxxxx ( the xxxx is the pv name from reportpv.out)
do
lspv xxxxx | grep IDENTIFIER ( the xxxx is pv name)
done reportpv.out
done reportvg.out

can anyone help me on this.

thanks

In one shot (not considering you want separate report files) I might do something like this:

for MyVG in `lsvg`
do
echo "\n\n Volume Group: $MyVG\n------------------"
for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
do
MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
echo $MyPV $MyID
done
done

i got it..

my script is ....

#!/bin/ksh
#Removing Old Files.
rm output
rm reportvg.out
rm reportpv.out
rm errors
#List of Volume Groups.
lsvg >> reportvg.out
#Creating file for output.
touch output
touch errors
echo "List of Volume Groups and Physical Volume:" >> output
while read -r line
do
echo "Volume Group Name: " $line >> output
lsvg -p $line > reportpv.out
while read -r line
do
#echo "Physical Volume Name: " $line >> output
lspv $line | grep 'PHYSICAL VOLUME' | awk '{print $1 " " $2 "\t" $3}' >> output
lspv $line | grep 'PV IDENTIFIER' | awk '{print $1 " " $2 "\t" "\t" $3}' >> output
done < reportpv.out
echo " " >> output
done < reportvg.out

it works beautiful...
thanks

Just a minor observation:

Don't let era, our local "herder of useless cats", see that ;-)) :

.... awk '{ /PV IDENTIFIER/ print $3 }'....

would do the same as "....grep ...| awk ....", yes?

I have long given up on pointing out that backticks are considered harmful in the Korn shell and "`...`" should be replaced by "$(....)".

And for the audience: please use [ code ]...[ /code ]-tags when posting code. The difference is:

with code-tags:

for MyVG in `lsvg`
do
     echo "\n\n Volume Group: $MyVG\n------------------"
     for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
     do
          MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
          echo $MyPV $MyID
     done
done

and the same without:
for MyVG in `lsvg`
do
echo "\n\n Volume Group: $MyVG\n------------------"
for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
do
MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
echo $MyPV $MyID
done
done

bakunin