Shell script execution when mail is recieved

Shell script execution when mail is recieved

Post by Michael Woodso » Mon, 17 Jul 1995 04:00:00



Briefly:
Is it possible to execute a shell script when mail has been inserted into
my inbox regardless of whether or not I am logged onto my account?  

Details:
I don't have access to a CGI-bin, so the only way for me to use forms (on
the net) is to have there output mailed to me.  I have written a script
which scans my inbox for form output, and then processes it.  Currently
the only way for me to run the script is to either manually execute the
command when I know I have information in my inbox, or to lock the
program in a while loop and wait till it finds information in my inbox.  
The former is impractical, and the latter, although it works, rudely uses
a great deal of proccessor time.
So I need to know if it is possible to execute the script immediately
when mail is inserted into my inbox?

            Michael Woodson

 
 
 

Shell script execution when mail is recieved

Post by Timothy Litt » Tue, 18 Jul 1995 04:00:00


: Briefly:
: Is it possible to execute a shell script when mail has been inserted into
: my inbox regardless of whether or not I am logged onto my account?  

: So I need to know if it is possible to execute the script immediately
: when mail is inserted into my inbox?

I think it is possible.  This is normally called an auto-reply or
canned response script (and although it's often done in PERL or
with ELMs filter, it's possible with shell commands).

First, set your .forward file to read something like
"| your-script"

Then write your script so that it will copy all incoming data into your
mail spool file.  This way, whenever mail comes in, it is piped to your
script (which must then be executed) and then is written out to your
normal mailbox.

It is important that you actually make sure you copy all incoming data
to the mail file OR you won't be getting any new mail (until you either
fix your script OR delete your .forward file).

During testing, I suggest you not keep your .forward file piped into
your script while you are not logged on (until after you are certain
it works correctly).

Tim...

 
 
 

Shell script execution when mail is recieved

Post by Phil Edwar » Wed, 19 Jul 1995 04:00:00




+ Briefly:
+ Is it possible to execute a shell script when mail has been inserted into
+ my inbox regardless of whether or not I am logged onto my account?  

Yes, BUT a word of warning:  if multiple message arrive within a
short period of time, Bad Things can happen to your mail unless you
are extremely careful with the use of lockfiles.  Because shell
scripts run very, very slowly compared to executables, you generally
do not want to launch a script on receipt of mail.

I would suggest install a mail filtering program such as filter
(comes with elm) or better yet, procmail (which I know for a fact
will do exactly what you want).  Thus, you can have procmail detect
an incoming CGI form and then shunt that individual message to your
own processing script one at a time, so that 1) the script can play
it safe, and 2) you don't have to tie up the script with non-CGI
mail.

The general syntax to shunt *any* mail message to a program
(executable, script, etc) is to put an entry in your .forward file:


The entries are separated by commas.  This entry would send one copy
of your mail to the "vacation" program, and forward a second copy to
me (please don't do that :-).

--

http://www.cs.wright.edu/people/students/pedwards/
The gods do not protect fools.  Fools are protected by more capable fools.

 
 
 

Shell script execution when mail is recieved

Post by Michael Sternbe » Thu, 20 Jul 1995 04:00:00



>Is it possible to execute a shell script when mail has been inserted into
>my inbox regardless of whether or not I am logged onto my account?  

Yes.  You have to create a file .forward in your home directoy
containing:

| "command line"

This way, incoming mail is fed as stdin to the command you name.
See the sendmail man page for details.

Greetings, Michael
--

Case Western Reserve University         Lab phone: (216) 368 4034
"Who disturrrbs me at this time?"     << Zaphod Beeblebrox IV >>

 
 
 

1. Execution of SQL Script thru shell script

hi all,
I have a piece of SQL code(some insert statement). Unix server. Oracle
DB.
I need to execute the sql code in the unix shell ... as in as a part
of a batch process...

i have a loginid password... for oracle
i believe that there is some sql command that can be embeded in the
shell script ? ne one aware ?

something like
sqlplus username/password ...
statement to execute sql file...
i need exact syntax...

Any help is appreciated !
regards

2. Installing/Booting Solaris using SCSI disk

3. How Can I control program execution in script shell ?

4. map_static exportfs RH6.0 server

5. Shell script hangs at execution of Java program...

6. PCI code on solaris 5.6

7. Recieving mail on my mail server.

8. ncsa 1.5.2 ignores some redirects, finds files it shouldn't

9. >> Shell Script Execution Question

10. Conditional execution in a shell script

11. Do comments in Bourne shell scripts slow their execution ??

12. Waiting on end of program execution from shell script?

13. How Can I control program execution in script shell ?