Operating System - HP-UX
1834435 Members
2380 Online
110067 Solutions
New Discussion

receive scrpit result by mail

 
SOLVED
Go to solution
kacou
Regular Advisor

receive scrpit result by mail

I have write a script for daily checking on my hpux server(B.11.23 U 9000/800).
1 - I want to receive the notification (result) by mail.
2 – i want again to program it for every morning

Help me please
7 REPLIES 7
Ivan Krastev
Honored Contributor

Re: receive scrpit result by mail

1. Redirect the script to send his output to a mail or include in script results to be collected in file and this file to be send via email.
2. Use cronjob to run the script. See man crontab.

regards,
ivan
kacou
Regular Advisor

Re: receive scrpit result by mail

what is the command for the first option (redirect)?
help me please
James R. Ferguson
Acclaimed Contributor

Re: receive scrpit result by mail

Hi Kacou:

#1: capture the return status of whatever you are running:

...
RSLT=$?
mailx -s "Result of process X=${RSLT}" root < /dev/null
...

#2: Setup your script (which includes the above) as a crontask. See the manpages for 'crontab'.

Regards!

...JRF...

James R. Ferguson
Acclaimed Contributor

Re: receive scrpit result by mail

Hi (again):

> what is the command for the first option (redirect)? help me please

If you need to ask that, you need to begin with some basic shell programming. This might be helpful:

http://docs.hp.com/en/B2355-90046/index.html

Regards!

...JRF...
Steven E. Protter
Exalted Contributor
Solution

Re: receive scrpit result by mail

Shalom,

http://www.hpux.ws/mailfile2

This script which you MUST modify before using will send any report you want as an attachment.

It can be modified to do many things.

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
Sandeep_Chaudhary
Trusted Contributor

Re: receive scrpit result by mail


command to send mail(should be part of script)

cat /tmp/scripts/report |mailx -s "Daily_Report_`hostname`" abcdsrrr@company.com >/dev/null 2>&1


schedule script in cron to send mail at 8 0 clock

0 8 * * * /root/scripts/dailycheck/DailyReport.sh >/dev/null 2>&1
Patrick Wallek
Honored Contributor

Re: receive scrpit result by mail

Why not combine the two options?

0 8 * * * /root/scripts/dailycheck/DailyReport.sh 2>&1 | mailx -s "Daily report" me@mydomain.com


Will run the script at 8:00 every morning and e-mail you the results. This way you don't necessarily need to worry with making sure all command output is sent to a log file, and then e-mail the logfile to yourself.