I recently needed to dynamically set an environmental variable from reading the Oracle Inventory XML file.
Typically you can find your Oracle Inventory location by looking here /etc/oraInst.loc on Linux or here /var/opt/oracle/oraInst.loc on Solaris. You should see the inventory_loc point to where your Oracle Inventory is located on your system. Once you get that you can look at the inventory.xml file in the ContentsXML folder to get a complete listing of all your Oracle installed software on your system.
Reading through that file you’ll see A LOT of stuff in there but you should be able to grep,sed,cut or awk your way through it to set the environmental variable.
Here’s how I did it when setting up my OEM_HOME variable.
function find_oem_home()
{
#find the Oracle Inventory location
export OS=`uname`
case $OS in
Linux)
#echo "Linux"
ORA_INV=`cat /etc/oraInst.loc | grep invent | cut -d= -f2`
ORA_INV_XML=$ORA_INV/ContentsXML/inventory.xml
OEM_HOME=`cat $ORA_INV_XML | grep oms12c1 | cut -d= -f3 | awk '{print $1}' | sed 's/"//g'`
export PATH=$OEM_HOME/bin:$PATH ORA_INV ORA_INV_XML OEM_HOME
;;
SunOS)
#echo "Solaris"
ORA_INV=`cat /var/opt/oracle/oraInst.loc | grep invent | cut -d= -f2`
ORA_INV_XML=$ORA_INV/ContentsXML/inventory.xml
OEM_HOME=`cat $ORA_INV_XML | grep oms12c1 | cut -d= -f3 | awk '{print $1}' | sed 's/"//g'`
export PATH=$OEM_HOME/bin:$PATH ORA_INV ORA_INV_XML OEM_HOME
;;
esac
}
Leave a comment