Operating System - HP-UX
1833187 Members
2950 Online
110051 Solutions
New Discussion

To find out some script sample for sending mail

 
SOLVED
Go to solution
kuotaiyi_2
Occasional Advisor

To find out some script sample for sending mail

where can find out some script sample which is for automatically sending mail at bachground.

I want to use this function to alert system status.

I already check sendmail is work. I can use mailer of CDE to send mail to my other internet mail account was successful.

please provide some comment.

Thanks.
Taiyi
5 REPLIES 5
Patrick Wallek
Honored Contributor
Solution

Re: To find out some script sample for sending mail

If you want to send the output of a command as an e-mail message you can do the following:

# some_command_to_run | mailx -s "subject" mail_address@domain.com

Or if you wish to send to contents of an ascii file as in a message do:

# mailx -s "subject" mail_address@domain.com < /path/to/some_text_file
RAC_1
Honored Contributor

Re: To find out some script sample for sending mail

Following is the script I use for space monitoring.

Script for d01 partition

thresh=98
actual=`bdf /d01|grep -v Filesystem|awk '{print $5}'|cut -c 1-2`

#Checks for thresh hold values.

if [ $actual -ge $thresh ] 2> /scripts/d01.err
then
echo $actual | mailx -s "d01 partition" 9823320605@orangemail.co.in else
echo $actual % at `date` >> /scripts/d01.stat
fi
There is no substitute to HARDWORK
MANOJ SRIVASTAVA
Honored Contributor

Re: To find out some script sample for sending mail

do a man mailx or sendmail to know th details , the genric format is

command | mailx user@domain.com

or mailx username@domain.com < /etc/passwd

you can also use -v option to get the see the system messages ie verbose option incase you find any errors.



Manoj Srivastava
John Meissner
Esteemed Contributor

Re: To find out some script sample for sending mail

I added this into a cron job so I could get sent reminders to my pager. I also add this into scripts so that I can be e-mailed notification if someone runs my script.

command to run | mailx -s "subject" -r return@address persontosendto

mailx -s "subject" -r returnaddress persontosendto < textfile

or lastly

cat file | mailx -s "subject" -r returnaddress persontosendto
All paths lead to destiny
harry d brown jr
Honored Contributor

Re: To find out some script sample for sending mail

for i in `echo filename1 filename2 filename3 ...`
do
uuencode $i $i.txt
done|mailx -m -s "test" username@whereever.com


live free or die
harry
Live Free or Die