DISQUS

techniQal support: How to Run a Script from Email

  • Kyle · 1 year ago
    Can you think of a way to have a bash script check email and then do something if it sees keywords in the email?
  • Daniel · 1 year ago
    Sorry -just caught this Kyle. Depending on where the mail lives, you could always schedule a cron job to script to go fetch mail, and based on content of the mail, run a command. The script would just use existing *nix tools for text matching/processing(grep,sed/awk).

    The benefit to the method I describe here, is that you don't have to worry about the mail handling piece in you script. The script takes the mail content as stdin, and works with it as it comes in.

    If you are comfortable with perl, python, or php, all 3 have fairly mature email libraries that would allow you to fetch and parse the emails from some other server source (IMAP, POP3, etc.) .

    Hope that helps.