Click to See Complete Forum and Search --> : How to send an email in a script


Ben Torrey
07-31-2001, 08:47 AM
Hi There,

I'm trying to have a script send me email once a day to just make sure that my mailserver is up.

I know I can send email from a command line by doing

mail bdog -s "Mail server is working"
. [ona new line]
Press [CTRL] + D

Is there a send-keys equivalent for a shell script, so that I can autosend this email??

thanks for any help!
Ben

YaRness
07-31-2001, 09:08 AM
i remember at school on the hp-ux machines i'd use a combination of cat and elm, like


cat foo.txt | elm email@foo.com

at least i think that's what i did. maybe you could do something similiar with the echo command and some email program. just make a script with the commands and have a cron job run it.

also this question MAY get more responses if it had been posted in the programming/script depot. although the question is simple enough that someone will prolly be able to answer it here, so don't cross-post it.

emanonii
07-31-2001, 11:27 AM
I do the same thing for my job (although I look for a process)(this is an over simplified example):
DATE=`date`
export DATE
ps -ef |grep process > process.txt
mail -s "Status of process at $DATE" joe < process.txt

That's it!

[ 31 July 2001: Message edited by: emanonii ]