1834282 Members
2129 Online
110066 Solutions
New Discussion

script help

 
SOLVED
Go to solution
kholikt
Super Advisor

script help

Hi,

I am writing some script to extract onmimm output and convert it into delimited text for example Pool name;Write Protected. With my current script it has to do omnimm twice to extract the Pool name and write-protected column.

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

PWP=$(omnimm -media_info $MEDIA -detail | awk -F ":" '/Write-protected/{print $2}' | sed 's/ //')

How could I do this in one line.

omnimm -media_info ESC_HTLSAPDEV2_WED_A -detail


MediumID : 0a140507:41078490:4622:0001
Pool name : HTL_htlsgsap_dev2
Library :
Medium Label : ESC_HTLSAPDEV2_WED_A
Location :
Medium Owner : mwscm.esc
Used blocks : 312175232
Total blocks : 312175232
Number of writes : 4
Number of overwrites : 12
Number of errors : 0
Creation time : Wed Jul 28 18:48:48 2004
Time of last write : Thu Jan 20 07:04:02 2005
Time of last overwrite : Thu Jan 20 03:00:49 2005
Time of last access : Thu Jan 20 07:04:02 2005
Medium type : HASNOCOPY
Write-protected : No
abc
3 REPLIES 3
c_51
Trusted Contributor

Re: script help

something like this would work

omnimm -media_info $MEDIA -detail | awk '
/^Pool name/{print $4;}
/^Write-protected/{print $3;}' | read POOL PWD
c_51
Trusted Contributor

Re: script help

oops my last will give two lines of output which isn't quite going to work

you'll need to do something like this

omnimm -media_info $MEDIA -detail | awk '
/^Pool name/{printf("%s ",$4);}
/^Write-protected/{print $3;}' | read POOL PWD

or probably more easily understandable/read

omnimm -media_info $MEDIA -detail | awk '
/^Pool name/{pool = $4;}
/^Write-protected/{pwd = $3;}
END {print pool, pwd;}' | read POOL PWD
Hein van den Heuvel
Honored Contributor
Solution

Re: script help

pipe into:

awk '/^Pool/{p=$4}/^Write/{print p ";" $3}'


Hein.