[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using mail in scripts



On Tue, Nov 13, 2007 at 03:32:39PM +0000, cs wrote:
> Folks, I have a bash script and I wanted to be able to catch a situation
> and then send an email to the user flagging this. However, the -s to
> `mail` doesn't allow spaces and I cannot work out, despite several
> attempts, how to escape/quote etc in order to do what I want. Here's
> what I'd like to do:

maybe this might do it.

> 
> #!/bin/bash -x
> TEMPFILE=`mktemp /tmp/chk_procs_XXX`
SUBJECT="$0 error"
> trap "date|mail -s $SUBJECT michael@there.com;echo Error - aborting;\
> exit" ERR

note the quote change in 'trap'

A

Attachment: signature.asc
Description: Digital signature


Reply to: