Posterous

various ramblings

-- justin kelly

  • Blog
  • Home
  • Contact me
« Back to posts
  • Viewed
    times

Filed under

  • bash
  • linux
February 1, 2010

bash: how to send emails in a script

  • Edit
  • Delete
  • Tags
  • Autopost

simple example to send an email if $message is not null

 
SUBJECT="Automated Security Alert" 
TO="alarms@someaddress.com" 
 
$message '' # if error or alert then create a message 
 
if [[ -n $message ]] 
then 
 echo $message 
 /bin/mail -s "$SUBJECT" "$TO"