![]() |
![]() |
![]() |
![]() |
Razor encourages the use of an often overlooked capability on UNIX systems; the ability to send e-mail directly into a program or script (as opposed to sending it to a specific user). The mechanics for doing this are fairly straightforward, and allow for a great deal of flexibility and power.
To best understand how this works, we'll explore it in the context of an example.
The issues program allows for specific e-mail addresses to receive a message on certain state transitions, as defined in the Permissions file1. Suppose, however, that rather than always sending e-mail to a fixed address, we wanted to notify the originator of an issue when the issue is Closed. A common approach is to use the Permissions file, but instead of having the issues program send e-mail to a user account, it sends the message directly into a shell script which decides the best route for further e-mailings.
The first step is to write the script itself, a variation of which is shown below. (A more fully commented form of the script can be found in the Razor release in the file
$RAZOR_HOME/examples/notify_on_closure.)
#! /bin/sh FULLTEXT=/tmp/$$.1 cat > $FULLTEXT . /local/razor_db/rz_prep.sh . $RAZOR_HOME/scripts/rz_toolbox INUM=`egrep 'Issue.*has been mod' $FULLTEXT | cut '-d ' -f3` RAZOR_GROUP=++ISSUES++ razor_learn $INUM INFO_FILE=$RAZOR_UNIVERSE_DIR/DOMAIN_01/++ISSUES++/Info/$INUM ORIGINATOR=`nawk '/STATE.*Submit/ {print $4}' $INFO_FILE` WHEN=`nawk '/STATE.*Submit/ {print $3}' $INFO_FILE` mail -s "$INUM has been closed" $ORIGINATOR << -EOF1- FYI... Issue number $INUM, (which you originated on $WHEN) has been closed out. Title: $RAZOR_Title Priority: $RAZOR_Priority -EOF1- exit 0
In brief, the script is performing the following steps...
The second step is to make the appropriate modifications to the Permissions file. Fortunately, the format of the file is fairly straightforward3. All we need to do is add a fourth field to the lines controlling the permissions of who can bring the issue to the closed state. Examples of the related lines are shown below...
... SubmittedClosed
*
closure No-Action
Closed
*
closure Active
Closed
*
closure Completed
Closed
*
closure Closed
Closed
nobody ...
Now, whenever an issue is transitioned into the Closed state, an e-mail message will automatically be generated and sent to `closure'.
The final step in accomplishing this is to make an appropriate entry in the /etc/aliases file for your site. You must establish an e-mail address which pipes the message directly into the script. In the example below, we've named the alias to be the same as the script name itself in the hopes of reducing confusion, so the line in /etc/aliases would look like...
closure: "|/local/razor_db/RAZOR_UNIVERSE_DIR/Scripts/ closure"
Note that the above edits require superuser assistance, and it will most likely need to be followed by the running of newaliases and/or other programs to fully enable the address for your network.
![]() |
![]() |
![]() |
![]() |
(Part 12 of 13 for this section) (Generated 09/13/99 at 18:14:47) |
Copyright Tower Concepts http://www.tower.com Voice: 315-363-8000 Fax: 315-363-7488 support@tower.com sales@tower.com |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |