1755763 Members
2892 Online
108838 Solutions
New Discussion юеВ

script help

 
SOLVED
Go to solution
kholikt
Super Advisor

script help

Hi,

I am writing a script to check the quality of the media in my omniback.

POOL=$(omnimm -media_info $RESULT | awk 'NR > 3 {print $3}')
QUALITY=$(omnimm -list_pool $POOL | grep -i $RESULT | awk '{print $1}')

However due to the length of my media pool, I won't be able to get the correct output.

For example, same media due to the column width problem _DDS was cut off. If I use "-detail" option I find it difficult to grep out the media pool name.

omnimm -media_info ESC_PBP_ARC_THU -detail

MediumID : ac1e1e1c:3d0d5c27:6672:0001
Pool name : PBP_SAP_Archive_DDS
Library :
Medium Label : ESC_PBP_ARC_THU
Location :
Used blocks : 309824
Total blocks : 40960000
Number of writes : 2
Number of overwrites : 85
Number of errors : 0
Creation time : Mon Jun 17 11:48:55 2002
Time of last write : Thu May 6 11:31:20 2004
Time of last overwrite : Thu May 6 11:30:19 2004
Time of last access : Thu May 6 12:47:20 2004
Medium type : HASNOCOPY

omnimm -media_info ESC_PBP_ARC_THU

Medium Label Medium ID Pool Library
===============================================================================
ESC_PBP_ARC_THU ac1e1e1c:3d0d5c27:6672:0001 PBP_SAP_Archive
abc
5 REPLIES 5
Hein van den Heuvel
Honored Contributor

Re: script help


using perl this would look something like:
(untested!)

perl media-check.pl $RESULT

where media-check.pl would be
-----
$result = shift or die "please specify result";
foreach $_ (`omnimm -media_info $result -detail`) {
if (/^Poolname:(\w+)/) {
$pool = $1;
last;
}
}
foreach $_ (`omnimm -list_pool $pool`){
if (/$result/i) {
@words=split;
print "$words[0]\n";
last;
}
}

-----

hth,
Hein.
V.Tamilvanan
Honored Contributor
Solution

Re: script help

Hi,

The below script should help you.

POOL=$(omnimm -media_info $RESULT | awk -F ":" '/Pool name/{print $2}')


To check by commandline.
omnimm -media_info omniback_1 -detail|awk -F ":" '/Pool name/{print $2}'

kholikt
Super Advisor

Re: script help

Hi,

It work but it put one more space character in the front
abc
Jdamian
Respected Contributor

Re: script help

trya to parse the output of omnirpt command:

omnirpt -tab -ascii -report media_list
Hein van den Heuvel
Honored Contributor

Re: script help


> It work but it put one more space character in the front

That's proably because it is hard to judge in the forum listing whether there are supposed to be spaces around the ":" on the -detail report lines or not. If there are spaces, then you do not need ":" as seperator and the example from Tamil becomes:

POOL=$(omnimm -media_info $RESULT | awk '/^Pool/{print $4}')

THis looks for a line beginning with (^) "Pool" and prints the 4th field. The first field would be "pool", the second "name", the 3th ":" and the name itself #4

Because the name is the last field you can also not worry about coutnign fields yoursef and use:

POOL=$(omnimm -media_info $RESULT | awk '/^Pool/{print $NF}')

NF = number of fields