Invoke a shell script in case mail with a specific subject is received

Hello fellow forum members,

I have a script which returns a date (I can design the script to return the value in email), How can I design the script in AIX to invoke another shell script which performs some set of actions.

Procmail doesnt work in AIX.

create an alias with the pipe symbol as fhe first charracter, followed by thename of the script to execute. the email complete with headers will be the standard unput

Perhaps something like:-

# echo "user.email:   | /usr/libexec/mymailcheck.ksh" >> /etc/aliases
stopsrc -s postfix            # ... or whatever mail server you are using
startsrc -s postfix           # Ditto

Then a script like this as /usr/libexec/mymailcheck.ksh

#!/bin/ksh
while read line        # Read each line of the email input (including all headers and other stuff you normally never see)
do
   # Work out if we have a subject line and act on the subject
   linetag="${line%% *}"       # Get first word
   if [ "$linetag" = "Subject:" ]
   then
      subject="${line#Subject: }"
      logger "I have a subject \"$subject\""
      # Whatever else you want to do here too.......
   fi
done

Obviously do this on a test server and take a copy of /etc/aliases first.

Does that help at all?
Robin

I might be inclined to write it as:

IFS=":"
while read keyword data
do
if ["$keyword" = "Subject" ]
then
     if [ "$data" = "this is it" ]
      then
      do your stuff
      fi
fi
done

I would also retain the original email address in the alias file

my_email        my_email,|/usr/bin/myscript

Also you may have to run 'newaliases' to create an new hash table