Be careful when silently installing oracle database software by response file

Sometimes we’re not able to call the GUI (Graphical User Interface) to manually install oracle database step by step then it should be better method using response file edited to install it by silent mode.

However, we install oracle single instance or rac environment the first BIG step is to install database or grid software oracle offers the similar response file template for us thus there’re three number of critical steps (aka, keys) have been filled up, I listed them as below.

INVENTORY_LOCATION=
ORACLE_HOME=
ORACLE_BASE=

Usually the values of above keys are like this.

INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19.3.0/db_1
ORACLE_BASE=/u01/app/oracle

Yes, my shell script file (silent_install_database_software.sh) is as follows.

cat /tmp/silent_install_database_software.sh
installdir=$1
verdir=$2
mkdir -p 
mkdir -p /tmp/database/response
cd /tmp/database/response
> db_install.rsp
echo 'INVENTORY_LOCATION=' > db_install.rsp
echo 'ORACLE_BASE=' > db_install.rsp
echo 'ORACLE_HOME=' > db_install.rsp
db_install="/tmp/database/response/db_install.rsp"
sed -i 's/INVENTORY_LOCATION=/INVENTORY_LOCATION=\'"${installdir}"'\/app\/oraInventory/g' ${db_install}
sed -i 's/ORACLE_BASE=/ORACLE_BASE=\'"${installdir}"'\/app\/oracle/g' ${db_install}
sed -i 's/ORACLE_HOME=/ORACLE_HOME=\'"${installdir}"'\/app\/oracle\/product\/'"${verdir}"'\/db_1/g' ${db_install}

Afterwards we go to run the previous shell script with two number of parameters (of course, have given eXecute permission with +x for this script).

# /tmp/silent_install_database_software.sh /u01 19.3.0

At this moment we observed response file “db_install.rsp” has been filled up some stuff (see the 2nd highlight content in the preceding section) we expected. Everything goes well but if we use the parameter “/u01/wms” instead of “/u01” to call silent_install_database_software.sh linux will report this error sed: -e expression #1, char 49: unknown option to `s’.

How we can fix it?

I infer SED doesn’t escape the second “/” of “/u01/wms” fortunately we’re able to use another flag character (such as #, @ or !) to replace / because the values of those keys have included the several location path character / hence we have to add \ to escape /. Taking a look at the modified shell script (just listed sed portion).

sed -i 's#INVENTORY_LOCATION=#INVENTORY_LOCATION='"${installdir}"'/app/oraInventory#g' ${db_install}
sed -i 's#ORACLE_HOME=#ORACLE_HOME='"${installdir}"'/app/oracle/product/'"${verdir}"'/db_1#g' ${db_install}
sed -i 's#ORACLE_BASE=#ORACLE_BASE='"${installdir}"'/app/oracle#g' ${db_install}

Wow! After running /tmp/silent_install_database_software.sh /u01/wms 19.3.0 then cat db_install.rsp we discovered the stuff of db_install.rsp is right.

Hope to help you … happy Monday!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.