Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating a file via sendmail 1

Status
Not open for further replies.

SysAdminMike

IS-IT--Management
Dec 5, 2008
27
US
All,

I have a sql script that runs twice a day at 7am and 7pm. It outputs to /home/oracle/log/freespace.log

15 minutes later another cronjob needs to run that uses sendmail and sends the following from /home/oracle/bin/freespace.txt

to:address@domain.com
from:address@domain.com
subject:Daily Tablespace Report

Please do not reply to this e-mail as it cannot receive e-mail please send e-mail to address@domain.com alternatively if needed.

The following report is just a guideline, OPS will review these reports both times a day it comes to see if action needs to be needs to be taken. This report is sent to address@domain.com as well as address@domain.com.

If action needs to be taken, OPS will email the DL to alert these users of it.

EOF

I need to make the sendmail function replace the EOF text with the test from the log (/home/oracle/log/freespace.log) and send the e-mail.

I have tried added "cat -/home/oracle/log/freespace.log << EOF | /usr/sbin/sendmail -t" to the top of the freespace.txt file, but have had no luck.

Any ideas?

Thanks,

Michael

Thanks,

Michael
 
Not tried this but what about:-

cat freespace.txt freespace.log | /usr/sbin/sendmail -t

May need to unix2dos the freespace.log or look at uuencode
 
You could try -

/usr/lib/sendmail -t user@nowhere.com < cat file1 file2

that'll build the body of the message from both files.

 
cat freespace.txt freespace.log | /usr/sbin/sendmail -t

This worked perfectly!!!

Thanks to both of you :)

Thanks,

Michael
 
m4ilm4n,

You would need to use process substitution (if supported by your shell and OS) to redirect from a command like that, e.g.

Code:
/usr/lib/sendmail -t user@nowhere.com <( cat file1 file2 )

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top