Welcome Guest ( Log In | Register )


 
 
 
 
 
 

 
 
Oracle 

Performance Tuning Reference poster
 
Oracle training in Linux 

commands
 
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
c0d3
post Dec 17 2004, 09:07 PM
Post #1


Newbie
*

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
dave
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
Tom
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

tom
Go to the top of the page
 
+Quote Post
edwardstoever
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.

t.sh:
CODE
sqlplus system@test/password @dd.sql

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

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

Now run it:
QUOTE
$ ./t.sh

now check the spooled results:
QUOTE
$ more results.txt

'SUCCES
-------
SUCCESS


Hey it works!

Edward
wink.gif
Go to the top of the page
 
+Quote Post
JGarmany
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

#!/bin/ksh

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