Welcome Guest ( Log In | Register )



Performance Tuning Reference poster
Oracle training in Linux 

Oracle training Weblogic Book
Easy Oracle Jumpstart
Oracle training & performance tuning books
Burleson Consulting Remote DB Administration
Reply to this topicStart new topic
> remote connection to oracle db using bash script
post Dec 17 2004, 09:07 PM
Post #1


Group: Members
Posts: 3
Joined: 5-December 04
Member No.: 1,093

Dear Guys,
I would like to ask for a sample bash script on how can I connect to a remote oracle database. Thanks in advance.
Go to the top of the page
+Quote Post
post Dec 18 2004, 12:11 PM
Post #2

Advanced Member

Group: Members
Posts: 5,206
Joined: 8-October 04
Member No.: 785

how about write it yourself then we can check it over for you
Go to the top of the page
+Quote Post
post Dec 19 2004, 04:49 AM
Post #3

Advanced Member

Group: Members
Posts: 78
Joined: 30-September 04
Member No.: 731

Hi folks,

... bash connecting to an oracle database?
IŽd say: SQL*Plus is connecting to an oracle database, never seen a shell doing this directly wink.gif

So you will have to install an Oracle-client onto your system, configure tnsnames.ora and then have fun.

> sqlplus username@remote_database

Go to the top of the page
+Quote Post
post Dec 19 2004, 01:54 PM
Post #4

Advanced Member

Group: Members
Posts: 555
Joined: 29-October 04
From: California
Member No.: 923

It is true that a bash script cannot connect to the database, but it can run SQLPLUS. I am no Unix master, but I will give it a go on linux and see what we get.

sqlplus system@test/password @dd.sql

then you have to change the t.sh file so it can be executed:
$ chmod 777 t.sh

Then create the dd.sql file:
spool results.txt
select 'SUCCESS' from dual;
spool off

Now run it:
$ ./t.sh

now check the spooled results:
$ more results.txt


Hey it works!

Go to the top of the page
+Quote Post
post Dec 21 2004, 01:41 PM
Post #5

Advanced Member

Group: Members
Posts: 359
Joined: 18-March 04
Member No.: 57

I use bash as my shell but script using Korn. By placing


at the beginning of the script I tell Linux/Uninx to execute the script using the ksh shell. Here is part of a ksh script t