The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to send an email? aajan UNIX for Dummies Questions & Answers 1 06-12-2007 04:53 AM
How to Send email in UNIX cooolthud Shell Programming and Scripting 1 01-23-2007 08:49 AM
send email to more users duke0001 UNIX for Dummies Questions & Answers 4 03-21-2006 12:58 PM
Send email where # is in the email address - Using Unix jingi1234 UNIX for Dummies Questions & Answers 1 05-23-2005 11:23 AM
Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win) Vetrivela UNIX for Advanced & Expert Users 2 02-15-2005 10:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-27-2006
*Jess* *Jess* is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 52
Send email to user when condition met

Hi all,
I plan to write a shell script to inform users on their task when certain condition met.

example: If a
then email user on action a
else
email user on action b.

I'm pretty new in scripting, appreciate any suggestions.
Thanks.
  #2 (permalink)  
Old 06-28-2006
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
What shell are you using?
  #3 (permalink)  
Old 06-28-2006
*Jess* *Jess* is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 52
Bourne shell
  #4 (permalink)  
Old 06-28-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,753
start with something like this maybe:
Code:
#!/bin/sh

#
# email a message
#  $1 = action
#  $2 = count
#  $3= user@myplace.com


email_it()
{
    echo "Action: $1  count: $2" | \
     /usr/bin/mailx -s "Action notification" "$3"

}

if [ $action = "A" ] ; then
    email_it  "ACTION WAS A"  42  "john.smith@some.com"
else
    email_it  "ACTION WAS B"  42  "john.smith@some.com"
fi
  #5 (permalink)  
Old 06-28-2006
*Jess* *Jess* is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 52
Thanks a lot, I had get it done. Another question, the sender of the file will be Super-User <root@hostname>. I wish to change the root to the name of the script I wrote. Is it possible to do so? Thanks.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0