Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Password in scrypt withouth using "/ as sysdba"

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Hello All,
How can I hide the password on line 9 in the script below with using login as sysdba?

#!/bin/ksh

dbname=mydbname
export ORACLE_SID=$dbname
export ORACLE_HOME=/orahome/app/oracle/product/10.2.05/
. /usr/sislocal/$dbname/to$dbname

#log into database
sqlplus -s splex/password << EOF #want to hide password here, without using sqlplus -s "/ as sysdba"

set pagesize 0
set linesize 4000
set feedback off
set trimspool on

spool rowcount.txt;

select source_name from splex.count_match_vw;
spool off;
EOF
 
This will keep the username and password out of the command line so it can't be seen with a '[tt]ps -fe[/tt]' command while it's running.

Code:
#!/bin/ksh

USER=splex
PASS=splexpassword
DATABASE=mydbname

[b][highlight #FCE94F]sqlplus -s /nolog << EOF
conn  ${USER}/${PASS}@${DATABASE}[/highlight][/b]

set pagesize 0 linesize 4000 feedback off trimspool on

spool rowcount.txt;
select source_name from splex.count_match_vw;
spool off;

EOF

The username and password will still be visible in the script, but it won't be in the command line where anyone can see.

To further hide those you could put their definitions into a protected or encrypted file that the script can pull them from.
 
Thanks, SamBones.
Much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top