• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1431
  • Last Modified:

Connecting to a database via ksh script

How can I check if a particular database is running on the server and then connect to it via sqlplus from aksh script?

I get an ORACLE_SID from oratab file but then I am stuck.

Should I use

. oraenv

to set the environment and then

sqlplus -s "/ as sysdba" << $OUTFILE

or are there better ways?

Can anyone help?
0
YZlat
Asked:
YZlat
  • 2
  • 2
2 Solutions
 
sdstuberCommented:
using oraenv is fine


connecting as sysdba is not recommended unless you're doing an install or upgrade that actually requires those privileges
0
 
YZlatAuthor Commented:
if I use . oraenv, how do i specify which ORACLE_SID to connect to?
0
 
sdstuberCommented:
assuming you don't want to be prompted from within your script  set the SID and ASK variables first, then invoke oraenv

export ORACLE_SID=YOUR_DB_SID
export ORAENV_ASK=NO

.  oraenv

Open in new window

0
 
YZlatAuthor Commented:
Thank you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now