Accessing database through shell scripting

Hi,
I am working on unix environment and interested to know how to connect to database through shell scripting which when scheduled can generate a file with the data obtained from the database and save the file in my home directory.
Could anyone please let me know how the shell script can be developed for this.

Several ways to do this... one of the ways I have included below.
sqlplus -s loginid/password@instance_name @/path/to/sql/file/sample.sql
In the sample.sql file include
spool /your/home/directory/some_file.txt
select * from schema.table ##normal sql stuff here
spool off
exit

Hi,
I am working on unix environment and interested to know how to connect to database through shell scripting which when scheduled can generate a file with the data obtained from the database and save the file in my home directory.
Could anyone please let me know how the shell script can be developed for this.

On Mon, May 18, 2009 at 9:09 PM, akavaram via shellscript-l
<email@removed wrote:
>
>
> Hi,
> I am working on unix environment and interested to know how to connect to
> database through shell scripting which when scheduled can generate a file
> with the data obtained from the database and save the file in my home
> directory.
> Could anyone please let me know how the shell script can be developed for
> this.

dbaccess db_name
Hi,
I am working on unix environment and interested to know how to connect to database through shell scripting which when scheduled can generate a file with the data obtained from the database and save the file in my home directory.
Could anyone please let me know how the shell script can be developed for this.

Hi Greg
Thanks for your reply.
I will be great full if you please suggest a solution for the below :
How to disconnect the database through shell script?
In my script im trying to connect to two databases one after the other.
Problem is that when I run the script, It is connecting database-1 and does not disconnect and also it is connecting database-2.
Can you please suggest me command which will disconnect the database automatically.

Copyright 1998-2015 Ziff Davis, LLC (Toolbox.com). All rights reserved. All product names are trademarks of their respective companies. Toolbox.com is not
affiliated with or endorsed by any company listed at this site.