Operating System - HP-UX
1845938 Members
4083 Online
110250 Solutions
New Discussion

how to script a mail command

 
SOLVED
Go to solution
Maciej Szewczykowski
Frequent Advisor

how to script a mail command

hi all,
got HP workstation an several scripts running. one of them is responsible for creating daily archives. now: i would like it to warn me via e-mail in case one of the archived files is corrupted (no matter bout the verification procedure).
the question is: how to include a "mail" command within a script, so that a short communicate is generated and sent to an address given?
thanks in advance.
3 REPLIES 3
Mark Grant
Honored Contributor

Re: how to script a mail command

mailx -s "Here is the subject" me@mydomain.no << EOF
Here is the
text of the mail

It isn't too useful though
EOF
Never preceed any demonstration with anything more predictive than "watch this"
Rajeev  Shukla
Honored Contributor

Re: how to script a mail command

Hi,
If its shell scripts, then after the command you can verify the return code which is "$?" check if its not "0" that means the command did not complete successfully and you can then write your action like mailx or send an snmp trap.
John Carr_2
Honored Contributor
Solution

Re: how to script a mail command


mailx -s "URGENT WARNING" maciei@mydomain.com < /var/adm/syslog/syslog.log


:-) John.