Script based on input mail

Hi,

I am looking for examples of scripts which monitor for a mail from an id , say abc@xyz.com and if that comes, would reply with the contents of a file. The file is a dynamic status of some automated task.

Also as variations, I would send the a string as the content of the mail. That would executed and o/p would be replied. Ex:- 'df -k .' would get me the disk status.

Any examples are most welcome.

Thanks,

Sounds like procmail or mailfilter depending on whichever happens to be already installed, or more to your liking. Here's Procmail, for better or for worse:

# Match on envelope sender line (might not work if your MTA is different from mine)
:0
* ^From abc@xyz\.com\>
{
   # save a copy for archiving / auditing
   :0c:
   fromabc

   # respond with df -k . output
   :0
   | ( formail -r ; df -k . ) | $SENDMAIL -t
}

This is very bare-bones and doesn't do any loop control; you'll find safer, better examples in the procmailex manual page.