How to setup Oracle connection inside shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to setup Oracle connection inside shell script?
# 1  
Old 03-12-2013
How to setup Oracle connection inside shell script?

Hi,

We have Oracle Connection parameters set up in file name "TESTDB" at location /abc/etc.When I try to run my shell script it does not connect to Oracle database. Please let me know how "TESTDB" file can be called inside script.
Code:
####################### Setting the directories #############################
CFG_DIR=/abc/etc/TESTDB
#################################################################################
#------Truncate the base table before loading today's data -------#

${ORACLE_HOME}/bin/sqlplus ${ORACLE_USER}/${ORACLE_PASSWD}@${ORACLE_SID} << EOF >> ${LOG_FILE} 2>&1
set serveroutput on;
TRUNCATE TABLE TBL_STG_LOAD;
COMMIT;
QUIT;
EOF

To run the script: $ > . ./scriptname.sh

Thanks
Sandy
# 2  
Old 03-12-2013
Source your file:/abc/etc/TESTDB in your script right before trying to connect to DB:
Code:
. /abc/etc/TESTDB

OR
Code:
source /abc/etc/TESTDB

This User Gave Thanks to Yoda For This Post:
# 3  
Old 03-12-2013
What I see is that you are using a lot of variables... Are they correctly set before you execute your shellscript?
Execute it in debug mode and see what is says...
This User Gave Thanks to vbe For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script verify connection to Oracle if not successful

i have a script that connects to the oracle database and executes the query statements. it works fine and i would like to add some message to check if the connection to oracle is not successful. basically this is the code snippet: #!/bin/sh ... ... ... sqlplus -s username/password@dbName... (2 Replies)
Discussion started by: wtolentino
2 Replies

2. UNIX for Dummies Questions & Answers

How to fix connection to Oracle database through shell script?

I have a question regarding how to connect to Oracle Database through shell script. 1. If I want call a stored procedure on Linux server as this, it works. $sqlplus /nolog SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 12 14:49:49 2015 Copyright (c) 1982, 2014, Oracle. All rights... (2 Replies)
Discussion started by: duke0001
2 Replies

3. Shell Programming and Scripting

Setup sftp connection

To set up a sftp connection between Server A, Server B and a website.com A batch script will start from Server A and Server B and Connect to the Website server How to setup sftp connection between server's. (1 Reply)
Discussion started by: aix_admin_007
1 Replies

4. Shell Programming and Scripting

How the user will provide the parameters for Oracle db connection in a shell script?

I'm new into unix. My question: is possible to write a shell script which will ask for the ORACLE_HOME, ORACLE_SID, USERNAME, PASSWORD to connect to Oracle db. In generally we have to set the ORACLE_HOME in .profile file. And after putting the 'sqlplus' command it asks for the username &... (6 Replies)
Discussion started by: priya001
6 Replies

5. Shell Programming and Scripting

Verifying oracle connection from shell script

Hi, Oracle 9.2 Solaris 10 From the shell script ........How can we verify whether oracle connection is successful or not ? Shell script will prompt the user to enter the oracle schema username, password and tns name. So, *how to verify whether oracle connection has been established or... (14 Replies)
Discussion started by: milink
14 Replies

6. Shell Programming and Scripting

oracle connection from shell script

Hi, For connecting to oracle my script is using the command sqlplus username/password@db_instance_name.For this to work i am setting ORACLE_HOME,TNS_ADMIN and ORACLE_SID in a seperate script.My question is,could we make a connection to oracle just by the command sqlplus... (4 Replies)
Discussion started by: DILEEP410
4 Replies

7. UNIX for Advanced & Expert Users

setup X connection

I am running on a linux in my company's main site. Sometimes I need to access to a server in another site and run some x-applications. I tried to SSH to that server, but had difficulty setting up the correct DISPLAY variable. I used "who" to list the users and got something like:... (2 Replies)
Discussion started by: johnjohn
2 Replies

8. Shell Programming and Scripting

shell script- oracle connection problem

Hi all, I am having problem with a shell script. I have a couple of csv files. The shell script will do some operation on them, create a sql file which will then be called by sqlplus. The problem is to gracefully exit sqlplus at the end of every operation as I do not want to hang on to the... (4 Replies)
Discussion started by: nattynatty
4 Replies

9. UNIX for Advanced & Expert Users

setup internet connection

HI.. i was wondering if someone out there can help me setup my internet connection.... i have no clue how to set it up.. could you please tell me step by step how to set it up.. i have a static ip, im using a cable modem to connect. my os is solaris 8. Please email me at lil_souldier@hotmail.com... (2 Replies)
Discussion started by: souldier
2 Replies
Login or Register to Ask a Question