1825805 Members
2124 Online
109687 Solutions
New Discussion

STDN of a Mail message

 
SOLVED
Go to solution
Kevin Wright
Honored Contributor

STDN of a Mail message

I have written a script that greps for certain strings on /var/mail/user and then takes neccessary action. I can run this script in cron every 15 minutes. However, I want to run the script only when a new message comes in..I can add the following line to the users .forward file
| /usr/contrib/bin/notify
this sends the message as stdn to the script notify,

but how do I modify the notify script te READ the stdn? an example would be greatly appreciated. thanks
1 REPLY 1
Curtis Larson
Trusted Contributor
Solution

Re: STDN of a Mail message

depends if you need the whole message to operate on or if you can handle the message one line at a time.

If you need the whole message, write it to a temporary file, do your operations, then remove it:

awk '{print $0;}' > tmpfile
stuff
rm tempfile

If you can do things one line at a time you can write awk script:

awk '
pattern { do this;}
' etc. or put a read statement in a while loop:

while read this
do
case $this in
stuff) do this;;
easc
done