mail command automated in a script

  • Follow


Please help in creating this shell script, its to email users regarding
a process status

I want to generate a email from a system, attach a log file to it,
everytime this script is run, towards the end of it

mail a1@a1.com, a2@a1.com, b2@b1.com

how to include this in the script, i want to avoide the ^C everytime
and automatically see my emails thru.

Thanks

JN

0
Reply Unix 11/22/2005 4:41:27 PM

Unix-Solaris wrote:
> Please help in creating this shell script, its to email users regarding
> a process status
> 
> I want to generate a email from a system, attach a log file to it,
> everytime this script is run, towards the end of it
> 
> mail a1@a1.com, a2@a1.com, b2@b1.com
> 
> how to include this in the script, i want to avoide the ^C everytime
> and automatically see my emails thru.

If what you want is in a file:

	mailx \
		-s "subject goes here" \
		a1@a1.com a2@a1.com b2@b1.com \
		< message-body

If you want to pipe some commands into it:

	{
	    date
	    echo "------ 'myfile' follows ------"
	    cat myfile
	    echo "------ end of 'myfile' -------"
	} |
		mailx \
			-s "subject goes here" \
			a1@a1.com a2@a1.com b2@b1.com

If you really need to *attach* a file (as opposed to just including
it in the content of the message), the easiest way to do that is
to install the "mutt" mail client ( http://www.mutt.org/ ), which
lets you attach files with the "-a" command-line option.

Hope that helps...

   - Logan
0
Reply Logan 11/23/2005 12:08:05 AM


1 Replies
869 Views

(page loaded in 0.032 seconds)

Similiar Articles:













7/20/2012 5:57:33 PM


Reply: