|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 Last edited by honeym210; 09-05-2008 at 10:59 AM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
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 |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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: Code:
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
doneand 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 Last edited by bakunin; 09-06-2008 at 04:47 PM.. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dispaly IP address | Burhan | Solaris | 1 | 03-15-2007 07:20 AM |
| Issue with dispaly of special character like 'TM' | vbehal | UNIX for Advanced & Expert Users | 0 | 11-13-2005 03:15 AM |
|
|