SUMMARY: kick off shell script with Email

From: Bhavesh Shah (bshah_at_citadon.com)
Date: 02/18/05

  • Next message: ert weerr: "Root rights to a shell script?"
    Date: Thu, 17 Feb 2005 17:38:14 -0800
    To: <sunmanagers@sunmanagers.org>
    
    

    Thanks to all....

    The list is endless...to name a Few...

    Crist Clark

    Francisco

    Eric Scisson

    Alex Kruchkoff

    Bill R Willams

    Bochnic Williams J

    Lovely David P

    Owens Blaine C - Eastman

    Broun Bevan

    Michael DeSimone

    Alan Crosby

    Pankaj Agarwal

    Ian Clements

    Special thanks to Francisco and Crist Clark for providing me extended
    support..

    Well there are many ways this can be achieved, the only problem being a
    security Risk and some have suggested using PGP encryption in the shell
    script. Well if anyone can send me such script will be of great Help..

    Method I

    ----------

    In /etc/aliases, add something like:

    targetaddress: "|/path/to/your/script"

    After this run newaliases and any email sent to targetaddress will kick
    off the script..

    Method II

    -------------

    Install procmail. It can downloaded from http://www.procmail.org/

    The procmail rule you would need would probably look something like
    this:

    :0

    * ^From.*sender

    * ^Subject:.*scriptname

    | script

    Method III

    -----------

    Under the account on Solaris create a file named .forward in the home
    directory with the following entry:

    | /path/to/script

     To check email From and Subject field before triggering the script

    I would have the command you send the email to check the email message.
    Just checking the "From" address is probably not secure enough either.
    For example, if you have this in your aliases,

    runscript |/usr/local/bin/mailcheck

    A script like this checks the "From:" address and a static password
    (which still probably is not secure enough, a one-time password is
    probably the easiest thing to do, but beyond what I'm going to write up
    as an example),

    $ cat /usr/local/bin/mailcheck

    #!/usr/bin/perl

    $script=/path/to/script;

    $password = "your password";

    $addr_match = 0;

    $pwd_match = 0;

    while (<>) {

          if (/^From: My Address <my_address\@example\.com>/) {

                $addr_match = 1;

          } elsif (/^password: $password$/) {

                $pwd_match = 1;

          }

    }

    open(LOGFILE, ">/var/log/mailcheck.log");

    if ($addr_match && $pwd_match) {

          print LOGFILE scalar(localtime()) . " running script, $script\n";

          exec $script ||

                print LOGFILE scalar(localtime()) . " failed to exec
    $script\n"; } elsif ($addr_match) {

          print LOGFILE scalar(localtime()) . " no password or incorrect
    password.\n"; } elsif ($pwd_match) {

          print LOGFILE scalar(localtime()) . " incorrect \"From\" line.\n";
    } else {

          print LOGFILE scalar(localtime()) . " bad password and
    \"From.\"\n"; }

    Thanks a lot to all Gurus...

    B

    My original post was:

    Hi Gurus,

    I have a strange requirement. Hope someone can help me in this.

    Is there anyway we can kick the shell script from email?

    If I send an email from Blackberry or outlook Inbox to Sun Server and

    after receiving the email it should kick off the shell script.

    Also if Sun Server has to receive an email what needs to be done other

    than starting sendmail daemon?

    Any Help will be greatly appreciated.

    TIA

    B

    _______________________________________________

    sunmanagers mailing list

    sunmanagers@sunmanagers.org

    http://www.sunmanagers.org/mailman/listinfo/sunmanagers
    _______________________________________________
    sunmanagers mailing list
    sunmanagers@sunmanagers.org
    http://www.sunmanagers.org/mailman/listinfo/sunmanagers


  • Next message: ert weerr: "Root rights to a shell script?"

    Relevant Pages

    • Re: pop-forum Re: poplog-dev A look at Poplog on the Macintosh
      ... with the poplink command. ... When trying to make pglink produce a 'sh' rather than a 'csh' shell ... script for linking and when trying to make it put unexpanded environment ... using the shell script pglibr, ...
      (comp.lang.pop)
    • Files appear to be cross linked
      ... script requires a number of standard environment variables to be set ... so it calls a second shell script to set these at the session level, ... control should return to the first shell script, ... that the script executes to the last line prior to the displaying of ...
      (comp.unix.solaris)
    • Re: [PHP] Catch STDERR
      ... into your PHP script? ... Or do you just need STDOUT in one variable, and STDERR in another, ... Another option is to try to write a .sh shell script to get what you ...
      (php.general)
    • Re: Converting large bash script to TCL
      ... I know that TCL and shell scripting share a lot of similarities. ... The shell script ... Determine what it (the script) is supposed to do ... echo "WOULD YOU LIKE TO INSTALL NAC DRIVER ...
      (comp.lang.tcl)
    • Re: basic questions
      ... Setting a script that runs at 3:00 ... Set chron to run that shell script. ... Debug the GUI application with the REPL. ... You start up the Web browser, then browse the Web, visit a hundred ...
      (comp.lang.lisp)