Operating System - HP-UX
1843905 Members
3450 Online
110226 Solutions
New Discussion

How to get output of sql script in mail?

 
SOLVED
Go to solution
Deepu Chakravarty
Regular Advisor

How to get output of sql script in mail?

I have setup unix sendmail in HP-UX 11.11 box. I can send Mail from my unix box to smtp mail login id (NT box)(through .forward file)successfully. Now my requirement is as follows:
1. I need output of my selected oracle sql scripts in my smtp mail login id.
This oracle script can be run with cron job in the unix box and output should be mailed to my smtp mail login id.
Help is required to setup this requirement.

Thanks in advance.
8 REPLIES 8
Muthukumar_5
Honored Contributor
Solution

Re: How to get output of sql script in mail?

Execute the sql scripts and pipe into smtp mail login id.

./sqlscript | mailx -s "SQL output" mailId

it will do that.

Else redirect sql script execution results to a log file as,

$ ./sqlscript 1>/tmp/sql.log 2>&1
$ mailx -s "SQL Output" mailID < /tmp/sql.log

--
Muthu
Easy to suggest when don't know about the problem!
Steven E. Protter
Exalted Contributor

Re: How to get output of sql script in mail?

Shalom Deepu,

Any output can be redirected to email:

script | mailx -s "sql stuff" your@yourmail.com

If its big, you can just do it as an attachment.

http://www.hpux.ws/mailfile2

This little gem uses sendmail to send large files as an attachment.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Muthukumar_5
Honored Contributor

Re: How to get output of sql script in mail?

If you want to attach the script executed log informations then use uuencode with mailx as,

$ ./script > /tmp/sql.log
$ uuencode /tmp/sql.log sql.log | mailx -s "subject" mailid

--
Muthu
Easy to suggest when don't know about the problem!
Yogeeraj_1
Honored Contributor

Re: How to get output of sql script in mail?

hi,
you can also send directly from Oracle itself using the Utl_Smtp package.

see the following link:
http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Deepu Chakravarty
Regular Advisor

Re: How to get output of sql script in mail?

Hi Guys,
Thanks.

Pls clarify the following;
1 How sendmail will pick up the output from .forward file ?
Since output will be generated through a cron job to a out file.
Steven E. Protter
Exalted Contributor

Re: How to get output of sql script in mail?

Shalom,

sendmail's checks local mail via user name. If a .forward file is present, it is used to route the mail.

This is built into the standard sendmail.cf file. You can read it and search for forward or .forward

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Deepu Chakravarty
Regular Advisor

Re: How to get output of sql script in mail?

SHALOM,

Thanks to everyone who were participated in this thread. The issue is resolved.
Deepu Chakravarty
Regular Advisor

Re: How to get output of sql script in mail?

SEP's and Muthu's suggestion seemed to be more effective. However I thank to everyone who were participated in this thread.