How to parse the XML Oracle Inventory file ?

Short answer

Shell command to parse the XML Oracle central inventory to find all installed Oracle homes:

echo "cat //HOME[not(@REMOVED)]/@LOC" | xmllint --shell $(awk -F'=' '/inventory_loc/ {print $2}' /etc/oraInst.loc)/ContentsXML/inventory.xml | grep -Po '".*?"' | tr -d \" | sort -u

Useful for setup ORACLE_HOME variables or relink Oracle SW.

The detailed analysis of this shell command

The location of the central inventory can be determined by querying the file /etc/oraInst.loc.

awk -F'=' '/inventory_loc/ {print $2}' /etc/oraInst.loc

This location inside /etc structure is here described for Linux OS, for the other plaforms may vary.

The central inventory itself with description of the oracle homes is located in /ContentsXML/inventory.xml. I use the small utility xmllint to parse XML contents rather than grep,sed, or awk.

xmllint --shell

Loookup for XML element HOME (the condition not(@REMOVED) removes already deinstalled oracle homes)

cat //HOME[not(@REMOVED)]/@LOC

and finally the postprocessing of xmllint output with grep and remove unnecessary character with tr

grep -Po '".*?"' | tr -d \" | sort -u

Leave a Reply

Your email address will not be published. Required fields are marked *