Say you want to kill all processes spawned from your Oracle Home. In Linux/Unix there is a nice command that lets you achieve this very easily.
If your Oracle Home is /u01/app/oracleHome then any oracle related process will have oracleHome in it's name. To kill all such processes at once issue the command :
pkill -9 -f oracleHome
How to extract values from a java properties files in a bash/shell script
Let's say you have a java properties (sample.prop ) file that contains this :
There are 3 parts to this task: 1) Getting the line that contains the value we want 2) extract the value from that line 3) store it in a variable to be used later in the script
To do part 1 we can simply grep for the value of the property we need :
For example :
To do part 2 we pipe the output of part 1 into awk for extraction of the value we need
the -F option of awk sets the delimiter to be '=' and then we print the second record which is what we need
Finally to store this value in a variable we do :
ORACLE_HOST=myhost.us.oracle.comNow, if we want to extract values from this properties file and use it in a shell/bash script for let's say an automation task, how do we go about that.
MW_HOME=/scratch/codrguy/sandbox
DB_HOST=dbhost.us.oracle.com
There are 3 parts to this task: 1) Getting the line that contains the value we want 2) extract the value from that line 3) store it in a variable to be used later in the script
To do part 1 we can simply grep for the value of the property we need :
For example :
grep ORACLE_HOST sample.prop
this returns
ORACLE_HOST=myhost.us.oracle.com
To do part 2 we pipe the output of part 1 into awk for extraction of the value we need
grep ORACLE_HOST sample.prop | awk -F= '{print $2}'
this returns
myhost.us.oracle.com
the -F option of awk sets the delimiter to be '=' and then we print the second record which is what we need
Finally to store this value in a variable we do :
my_value=$(grep ORACLE_HOST sample.prop | awk -F= '{print $2}')
Subscribe to:
Posts (Atom)