Connecting database

Hi all,
In my concern they gave a task to me do cran job like
To write a shell script for

To connect a database
it should execute a query
it should save the output of the query
after getting the output it should send a mail to you inbox for every one hour

I can able to connect to database by wiriting the query plz help me in rest of the activity

Thanks in advance

Regards
Thelak

Please post the complete script you wrote so far.

Posted from my Samsung Galaxy S mobile.

sqlplus custom/custom123@abncntem

the above stuff will work to connect to the database

select count(*) GUP from gup
/
select count(*) SOD from sod
/
select count(*) GUPSIS from gupsis@csis
/
select count(*) SODSIS from sodsis@csis

the above shown stuffs will have to be in a sql file this should have to run after it connects to the database

ie(in the script file i should have to call this sql file)

You need to write more that than.... or at least write the pseudo code so people understand what you are doing.

Thanks.

---------- Post updated at 06:17 ---------- Previous update was at 06:17 ----------

You need to write more that than.... or at least write the pseudo code so people understand what you are doing.

Thanks.

#!/usr/bin/ksh
sqlplus custom/custom123@abncntem << EndOfFile
select count(*) GUP from gup ;
{blah blah blah}
quit
EndOfFile > output.txt

mailx -s "File" abc@abc.com < output.txt

HI

!/usr/bin/ksh
sqlplus insivs/Siva#shan11@fincncor << EndofFile
#sqlplus custom/custom123@fincncor << EndOfFile
spool count.txt
select count(*) GUP from gup
/
select count(*) SOD from sod
/
select count(*) GUPSIS from gupsis@csis
/
select count(*) SODSIS from sodsis@csis
/
spool off
quit
#mailx -s "file" thelak.kumar@###.com < count.txt

Every thing is working fine but am not receiving the mail,i tried in so many ways,any help
be appericiated
Its possible to to send mail with attachment?
I have to add this check in CRON JOB too please help
Thanks

First Check `mailx` service is enable on your server or not ?
If enable, U want database Query output in mail or Attachments in mail, confirm?

The output of the database query should have to append in a file and with that attachment mail have to send to my outlook

please review this

thnks in advance

\cat count.txt  | \ux2dos | \mailx -s "expected Db output..."  thelak.kumar@###.com