-1

i am trying to connect Oracle database from Linux server where environment variables and tnsnames.ora cannot be modified.

I am using following code to connect which is working fine and i am able to connect database using sqlplus.

export ORACLE_HOME=/opt/oracle/product/112030_cl_64/cl
export PATH=/opt/oracle/product/112030_cl_64/cl/bin:$PATH
sqlplus myuser/mypass@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(Host=x)(Port=x)))(CONNECT_DATA=(SERVICE_NAME=x)))

Now i am not able to find any solution how can i execute it so that i don't need to execute it manually every time and i don't want to share the password with anyone else. i want to connect db using sqlplus from a shell script to spool data.

any lead would be appreciable. Thanks in advance.

2
  • 2
    Maybe this? Commented Apr 11, 2019 at 11:18
  • 1
    Also what do you mean by 'showing' - are you concerned about someone else being able to see the password in your script (which you should be, however much you try to lock down privs), or only about anyone being able to see it via ps? Commented Apr 11, 2019 at 11:24

2 Answers 2

1

The cleanest way is to use Oracle Wallet to store database passwords and so that your scripts can use them. Otherwise if you can login as the oracle product owner ("oracle" most of the time) and it belong to the "dba" group you can connect as sys without typing the password (sqlplus / as sysdba) but it's privileged access, don't use it for business processes.

Sign up to request clarification or add additional context in comments.

Comments

0

Omit the password; you'll be prompted to enter it, but it'll be invisible (Windows example, but doesn't matter in this case):

M:\>sqlplus scott@orcl

SQL*Plus: Release 11.2.0.1.0 Production on ╚et Tra 11 13:01:35 2019

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>

That, of course, requires you to type it every time. If it is stored, somewhere, anyone else could see it. Perhaps there is a way, but I don't know it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.