Re: Novice question -- how to I run script in unix sqlplus?

From: jobowker <member_at_dbforums.com>
Date: 21 Jun 2002 06:15:57 GMT
Message-ID: <3d12c49d$5_at_usenetgateway.com>


The following script connects to each database (even if they are different oracle versions) and stops oraenv from asking you which sid. It then resets it back so that the next person to sign on will be asked again. The trick is for you to set your sid (here I loop through oratab) and then invoke oraenv to set your oracle path & such. If this doesn't make sense send me an email and I'll explain it. Hope this helps.

This is how I execute sql statements from a unix ksh script:

#!/bin/ksh
# Ensure user is oracle
 WHOAMI="`id -unr`" if [ ! "$WHOAMI" = "oracle" ] then echo "This script  can only be run by the oracle user." exit 1 fi export DBLIST=`cut -f1  -d: /etc/oratab|grep -v "^#" |grep -v "^\*"` for ORACLE_SID in $DBLIST  do ORAENV_ASK=NO ; . /usr/local/bin/oraenv ; ORAENV_ASK=""  $ORACLE_HOME/bin/sqlplus /nolog <<EOF connect / as sysdba select * from  dual; exit EOF done

--
Posted via dBforums
http://dbforums.com
Received on Fri Jun 21 2002 - 08:15:57 CEST

Original text of this message