Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with a UNIX Shell Script to create and execute a package in 50 databases

3334932Feb 10 2017 — edited Feb 15 2017

Hello

I need create a script to loop through the etc/oratab file to get the instance names, then login and execute  the package header and package body and apply grants. I want to skip any instances that have "lab" in the instance name. I'm very new to Unix.

Am I on the right track?

How would I be able to exclude the instances I don't want the script to run against?

#!/bin/sh
set -x
sids=`/bin/cut -d':' -f1 /etc/oratab`

for SID in $sids
do
ORACLE_SID=$sid
. /usr/local/bin/oraenv

if [grep -v lab $sid]; then

${ORACLE_HOME}/bin/sqlplus -s "/ as sysdba" << EOF
spool $1.log

echo $sids

#@C:\Assignments\Scripts\EMS.Pkg_SynkFixes.sql;
#show errors;

#@C:\Assignments\Scripts\EMS.pkg_SynkFixesbody.sql;
#show errors;

#create public synonym pkg_SynkFixes for EMS.pkg_SynkFixes;

#grant execute on EMS.pkg_SynkFixes to emsuserrole;
spool off

fi
exit;
EOF
done

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 15 2017
Added on Feb 10 2017
8 comments
1,104 views