To run script as a oracle user we have to use su command which means change user ID or become super-user
su [ - ] [ username [ arg ] ]
Pass the environment along unchanged, as if the user actually logged in as the specified user.
username The name of another username that you wish to log in as.
arg Additional arguments that need to be passed through the su command.
To run a script create_user.sql in oracle user use the following script
su - oracle -c $ORACLE_HOME/bin/sqlplus -s <<! / as sysdba @/home/oracle/create_user.sql disconnect !
To run some Java console base application from rc.local as a Oracle User
[oracle@www ~]$ vi /etc/rc.local #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local su - oracle /home/oracle/runApp.sh
Write a script to run a jar file as a demon process (use &), you can also run a class file in the same way.
[oracle@www ~]$ vi runApp.sh JAVA_HOME="/usr/java/jre1.6.0_14/" export JAVA_HOME export PATH=$PATH:$JAVA_HOME/bin java -jar /home/oracle/AktelCMP.jar &
N.B: You can also run pearl or any other application in the same way.