Get list of desired LUN id from powermt output

Small script to get LUN id from powermt output when supplied with list of disks. Its tedious job to extract LUN id from output when you have list of disks to wok upon.

You have a list of disk names from OS end and you need to get their respective LUN ids from powermt output.
This requires manual work of searching each disk name in output and then copying its respective LUN id. Typically these three lines you are interested in powermt output.
If you have list of disks to search its a tedious task. Becuase you have to search each and every disk name in output.
Solution :
Get ouput of powermt command in a file
Get all disk names in one file e.g. test.txt
Run a for loop which will get LUN id of each disk described in file. In this loop we are taking each disk and searching it in above file. Then we are extracting 2 below lines from disk name (since 2nd line below disk name contains LUN id). And then extracting LUN id from it with some data filtering.
You will be presented with the list of LUN ids for respective disks in the test.txt file! You can even echo disk name before LUN id by inserting echo $i just above cat command in above code.

Vice versa:
Get disk names by giving LUN ids in text.txt file. Its same logic, only difference is we will be extracting above 2 lines rather than below ones. Rest all procedure remains same.

SHARE

sangeethakumar

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment