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.
#!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:
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.