Operating System - HP-UX
1843983 Members
1987 Online
110226 Solutions
New Discussion

Sending a mail after script exec

 
SOLVED
Go to solution
Oliver Schmitz
Regular Advisor

Sending a mail after script exec

Dear all,

I want to send myself (on a remote maschine) a mail which contains the logfile which a script written by me produces. How can I do it? I played around with mail and mailx but I can not understand how to proceed.

Thanks for help.

Best Regards, Oliver
Oliver Schmitz
6 REPLIES 6
Bernhard Mueller
Honored Contributor
Solution

Re: Sending a mail after script exec

Oliver,


#!/bin/sh
LOGFILE=/tmp/mylog.$$
echo "done with this script" >> $LOGFILE
cat $LOGIFLE | mailx -m -s "Output of LOGFILE from `hostname` at `date`" root, xyz@my.domain.com
rm $LOGFILE
exit


Regards
Bernhard
doug mielke
Respected Contributor

Re: Sending a mail after script exec

will redirect do this?

mailx me@.com < scriptlog
James R. Ferguson
Acclaimed Contributor

Re: Sending a mail after script exec

Hi Oliver:

One way:

# mailx -s "LogFile" root@server.xyz.com < /var/adm/syslog/syslog.log

Regards!

...JRF...
Tom Geudens
Honored Contributor

Re: Sending a mail after script exec

Hi Oliver,
From one of our scripts ... (you'll have to fill in the variables ;-)

( echo "$errorswarm ($swarmbackup)\n\n\n"; cat $ERRORCODES; echo " ";cat $LOGFILETEMP ) |
mailx -s "$errorswarm ($swarmbackup)" $MAILERRORS

Regards,
Tom Geudens
A life ? Cool ! Where can I download one of those from ?
Jeff Schussele
Honored Contributor

Re: Sending a mail after script exec

Hi Oliver,

Here's an example

cat logile | mailx -s "Your Subject Here" username@company.com

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Tom Ward_1
Honored Contributor

Re: Sending a mail after script exec

Hello Oliver,

This should do it for you.

./your_script > /tmp/logfile; mailx -s "script_log" name@domain.net < /tmp/logfile

Or you could just add the mailx command to the end of your script.

Regards,
Tom