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.
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.
What shell are you using?
Bourne shell
start with something like this maybe:
#!/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
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.