[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Connecting to a database via ksh script

Posted on 2013-06-10
4
Medium Priority
?
1,411 Views
Last Modified: 2013-06-10
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
Comment
Question by:YZlat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 2000 total points
ID: 39235319
using oraenv is fine


connecting as sysdba is not recommended unless you're doing an install or upgrade that actually requires those privileges
0
 
LVL 35

Author Comment

by:YZlat
ID: 39235455
if I use . oraenv, how do i specify which ORACLE_SID to connect to?
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 39235531
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
 
LVL 35

Author Closing Comment

by:YZlat
ID: 39235589
Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Utilizing an array to gracefully append to a list of EmailAddresses
Via a live example, show how to take different types of Oracle backups using RMAN.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question