Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have been asked to setup an automated trigger on Unix upon receiving a certain kind of email from MS Exchange server.

The requirement is to trigger a shell script when any person from a fixed list of senders sends an email via MS Exchange server to a designated email account on unix.

For example:

Email from [email protected] (Exchange Server) sends an email to [email protected] (Linux) with the subject: Unlock Account X

This ideally should trigger a shell script that will have code to unlock Account X.

Is there a way to configure this on Unix so that upon receiving an email as described above, I can trigger a shell script?

share|improve this question

marked as duplicate by Anthon, Rahul, Kusalananda, Networker, Stephen Kitt yesterday

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4  
procmail might help you in this case – Rahul yesterday
    
Welcome to unix&linux @rob81. Please consider voting for good answers and marking one of them as an answer. – mazs yesterday
up vote 8 down vote accepted

There are multiple solutions to this problem. As suggested by Rahul in the comments, I would use procmail and edit .procmailrc to something like this:

:0
* ^From.*[email protected]
* !^FROM_DAEMON
* !^FROM_MAILER
* ^Subject:.*Unlock
| /path/to/your/script
share|improve this answer
    
thank you for this. Is there a way to manage this to also filter the subject and look for a specific string or a way to read the string in my shell script and perform the action based on it? – rob81 yesterday
    
@rob81 : If this solves the problem, you may accept it as an answer. :) – sjsam yesterday
    
@rob81 yes, see the edit. – user994144 yesterday
    
Thank you guys!!! – rob81 yesterday

Not the answer you're looking for? Browse other questions tagged or ask your own question.