Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Best approach to retrieve Connect String
Daniel Morgan wrote:
> Wes Brooks wrote: >
> > > I agree with Hans but also suggest you explore the possibility of using > externally authenticated accounts such as OPS$DEV, OPS$TEST, OPS$PROD1.
And lastly, if the previous two good suggestions won't work, here's an answer to your original question.
Assuming the unix user 'oracle' and group 'dba' are suitably secure (which they should be anyway), create one or more "password" files with file names matching the user and connect string.
[as user oracle, your directory structure may vary]
% echo "my_password" > ${ORACLE_BASE}/local/mysid.world.myuser.passwd % chmod ug+r,o-rwx ${ORACLE_BASE}/local/mysid.world.myuser.passwd
[the above makes the file readable only by owner and group]
2. Skeleton shell script for Solaris or Linux, line wrapping may need fixing:
------[cut here]--------------
#!/bin/bash
# connect information passed as args
CONNECT=$1
USER=$2
if [ ! -e ${ORACLE_BASE}/local/${CONNECT}.${USER}.passwd ]
then
echo "Cannot find file ${ORACLE_BASE}/local/${CONNECT}.${USER}.passwd, exiting..." exit
/bin/cat ${ORACLE_BASE}/local/${CONNECT}.${USER}.passwd \
| ${ORACLE_HOME}/bin/sqlplus ${USER}@${CONNECT} \ @${ORACLE_BASE}/sql/my_script \ 2>&1
A heck of lot better than hardcoding -- now you can change your passwords on a regular basis without editing every script each time, just the one-line "password" file(s).
For more security, flexibility, and control in scripting, Perl with DBI is highly recommended.
--Mark Bole Received on Sun Aug 15 2004 - 15:34:36 CDT
![]() |
![]() |