Connect to database from different unix box


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Connect to database from different unix box
# 1  
Old 04-30-2010
MySQL Connect to database from different unix box

Hi Friends,

I have a one unix box "x.y.z" on SunOS , where oracle is not installed. And another machine "a.b.c" on AIX , where oracle is installed. Now i want to make a script on x.y.z , that can connect to database on a.b.c, using sqlplus command. and then generate a report based on the database query output.

Thanks
Gaurav
Unix is in the blood !! Smilie
# 2  
Old 04-30-2010
The things you need is oracle client on xyz and an entry for SID for the database of abc which you want to connect in the tnsnames.ora of the xyz.

Are you sure with them?
# 3  
Old 04-30-2010
Hi Gaurav
Try this only if you cannot establish what anchal suggested before.
1. Keep the sql part of your script in a separate file.
2. Just before the sql part comes, do automatic ftp or rcp and place this sql script in the box in which oracle connection is present.
3. Followed by step 2 in your shell script, do an "remsh" and connect to the box2 and run the sql script



Thanks
Guru.

Last edited by Scott; 05-04-2010 at 08:35 AM.. Reason: Removed link
# 4  
Old 05-01-2010
My xyz is a production machine and I cant get the oracle client installed on it. However I think what guru suggested is workable in my case.

First I need to establish the connection to the machine abc and then execute the sql statements therein.

Does the code will look alike below ?

Code:
#!bin/ksh

telnet username/password@abc
sqlplus -s username/password@schema << report.txt

sql statements
exit
!

sftp username/password@xyz

mput report.txt /path on xyz
bye
exit


Last edited by pludi; 05-03-2010 at 02:29 AM..
# 5  
Old 05-02-2010
Hi Gaurav

Quote:
#!bin/ksh

telnet username/password@abc
sqlplus -s username/password@schema << report.txt

sql statements
exit
!

sftp username/password@xyz

mput report.txt /path on xyz
bye
exit
I was thinking like this:

Code:
#!bin/ksh

sqlplus -s username/password@schema << report.txt

sql statements
exit
!

sftp username/password@xyz

mput report.txt /path on xyz
bye
exit

remsh <connect to destination and run the script placed there>

Could think of one more better way if your entire script is to be run in the "abc" box. Write your script as if you are going to run directly on the "abc" box.

From the "xyz" box, you can run the script like this:

Code:
ssh <user>\@<box>  <your script in xyz>



Thanks
Guru.

Last edited by pludi; 05-03-2010 at 02:29 AM.. Reason: removed self-advertising signature
# 6  
Old 05-04-2010
Guru,

Thanks for the post , but I was willing to shoot the script from XYZ box and not from ABC.Thats why I established the connection to ABC first in my code and then ran sql query.However once the query will run on abc box through xyz script, where the spool file will get created by default on xyz or abc ??? Because if it is getting generated on ABC box then again i need to SFTP on XYZ and get the file on it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

connect Clearcase from unix box

Hi am using unix box and am always download code from clearcase. I need to connect clearcase server from my unix box using shell script.I need to create view baseline everything using the sript. am not mention I need a code. Just anyone help me start the concept to write a code. Thanks,... (1 Reply)
Discussion started by: ckchelladurai
1 Replies

2. Solaris

how to connect to wireless from virtual box

hi everyone... this is my first post here please help me with this..as iam new to solaris i have installed solaris 10 on virtual box.. and am not able to connect to the internet .. is there anyway i can get connect to the net.. please help me step by step if possible... thanks in... (1 Reply)
Discussion started by: yrajendergoud
1 Replies

3. UNIX for Dummies Questions & Answers

Connect MySQL database from Unix

How to connect a MySQL database from unix using unix shell scripting ( people are using perl scrpt to connect the same database). I want to access a MySQL database through a shell script (4 Replies)
Discussion started by: apsprabhu
4 Replies

4. Shell Programming and Scripting

How to connect with oracle database using unix...

Hi all I am working in datawarehouse project and use DB2 database . shell scripting is written to connect with DB2 database in my application but i dont know how to connect with oracle databse or other databases.Is there any command in unix to connect any of these datbases? (6 Replies)
Discussion started by: vijays3
6 Replies

5. Shell Programming and Scripting

How to COnnect to Oracle database from UNIX Box

I am trying to connect to Oracle Databse from UNIX box using sqlplus command. But i get sqplus not found message. $ sqlplus sqlplus: not found I have searched in forums and all are suggesting to set environment varaibles...can somebody tell me what variables to set and how to set.and the... (12 Replies)
Discussion started by: angelarosh
12 Replies

6. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

7. Shell Programming and Scripting

how will i connect postgres database from unix shell script

I have got the solution so just closing this issue. (3 Replies)
Discussion started by: jambesh
3 Replies

8. Shell Programming and Scripting

how to compare all files in one unix box has been to copied to another unix box

Hi our unix admin has copied all files from one unix box to new unix box. We just need to confirm that all the file systems are copied properly. How to validate. (9 Replies)
Discussion started by: sravanreddym
9 Replies

9. UNIX for Dummies Questions & Answers

Running UNIX commands remotely in Windows box from Unix box – avoid entering password

I am able to run the UNIX commands in a Windows box from a UNIX box through "SSH" functionality. But whenever the SSH connection is established between UNIX and Windows, password for windows box is being asked. Is there a way to avoid asking password whenever the SSH connection is made? Can I... (1 Reply)
Discussion started by: D.kalpana
1 Replies

10. Shell Programming and Scripting

How to connect to database db2 through Unix Shell Script

I am trying to connect to database db2 through shell script. The process I am trying is > db2 It gives me error Access Denied. While checking for access I have the rights. Is there ant other way round..? Please help. (3 Replies)
Discussion started by: ankitgupta
3 Replies
Login or Register to Ask a Question