Invoke a shell script in case mail with a specific subject is received


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Invoke a shell script in case mail with a specific subject is received
# 1  
Old 07-11-2017
Invoke a shell script in case mail with a specific subject is received

Hello fellow forum members,

I have a script which returns a date (I can design the script to return the value in email), How can I design the script in AIX to invoke another shell script which performs some set of actions.

Procmail doesnt work in AIX.
# 2  
Old 07-11-2017
create an alias with the pipe symbol as fhe first charracter, followed by thename of the script to execute. the email complete with headers will be the standard unput
# 3  
Old 07-11-2017
Do you have any code for it please?

Quote:
Originally Posted by jgt
create an alias with the pipe symbol as fhe first charracter, followed by thename of the script to execute. the email complete with headers will be the standard unput
# 4  
Old 07-11-2017
Perhaps something like:-
Code:
# echo "user.email:   | /usr/libexec/mymailcheck.ksh" >> /etc/aliases
stopsrc -s postfix            # ... or whatever mail server you are using
startsrc -s postfix           # Ditto

Then a script like this as /usr/libexec/mymailcheck.ksh
Code:
#!/bin/ksh
while read line        # Read each line of the email input (including all headers and other stuff you normally never see)
do
   # Work out if we have a subject line and act on the subject
   linetag="${line%% *}"       # Get first word
   if [ "$linetag" = "Subject:" ]
   then
      subject="${line#Subject: }"
      logger "I have a subject \"$subject\""
      # Whatever else you want to do here too.......
   fi
done

Obviously do this on a test server and take a copy of /etc/aliases first.


Does that help at all?
Robin
# 5  
Old 07-11-2017
I might be inclined to write it as:
Code:
IFS=":"
while read keyword data
do
if ["$keyword" = "Subject" ]
then
     if [ "$data" = "this is it" ]
      then
      do your stuff
      fi
fi
done

I would also retain the original email address in the alias file
Code:
my_email        my_email,|/usr/bin/myscript

Also you may have to run 'newaliases' to create an new hash table
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check email with attachment received or not from UNIX shell script?

Hello Guys, Here is the requirement!! I want to check the mail with attachment received or not through unix scripting. And send an notification email when mail with attachment already received. Any thoughts on this is much appreciated!! Regards, Harry (0 Replies)
Discussion started by: dharry2017
0 Replies

2. Shell Programming and Scripting

Problem while Invoke Shell Script function from Java Program

Hi, I have create a Shell Script, with one function. I want to call the script file in Java Program. It working fine. but the problem is the function in the Shell Script is not executed. Please suggest me, Regards, Nanthagopal A (2 Replies)
Discussion started by: nanthagopal
2 Replies

3. UNIX for Dummies Questions & Answers

Invoke a shell script on new email in inbox

Hello all, Is there a way I can invoke a shell script when ever a new mail is delivered to my account in solaris? Something like .forward file, instead of forwarding it to another email id, I want the email to be passed onto some shell script. Basically I want to extract the envelop... (3 Replies)
Discussion started by: atukuri
3 Replies

4. Shell Programming and Scripting

Shell script to invoke options automatically

i have a script which has 2 options. a b And a has 6 sub options. i want to write a script which will call the parent script and give options automatically. examle: linasplg11:/opt/ss/kk/01.00/bin # startup.sh /opt/ss/rdm/01.00 Please select the component to... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

5. Shell Programming and Scripting

How can i invoke SU command in shell script

Hi All , i am trying to switch user (from unix1 to unix 2 ) The user will give me the input and also the password . also how can i login into with the password . itried several attempts . no luck Can any one help on this !!! (4 Replies)
Discussion started by: raghav1982
4 Replies

6. Shell Programming and Scripting

Shell script to invoke db startup/shutdown

Hi all, I have a shell script which does db shutdown ..the script snippet which does this is as follows: function call_sql_plus { ${SQLPLUS:-sqlplus} -s /nolog <<EOF EXIT; EOF if then echo "Error occurred while calling sqlplus " ... (3 Replies)
Discussion started by: KrishnaSaran
3 Replies

7. UNIX for Dummies Questions & Answers

need to invoke a shell script from xml file.

hi all, forgive me if this question is not relevant to this section. i have a shell file that will automatically deploy the files that are necessary and will compile them. i need to automate this management process through cruise control, for this i need to know whether it is possible for me to... (2 Replies)
Discussion started by: sais
2 Replies

8. Shell Programming and Scripting

Bourne: How to invoke an alias from within a shell script

Bourne: How to invoke an alias from within a shell script If I type in the alias in the command line, it runs If I insert that same alias into my shell script and run the shell script, the alias is not invoked. Help please. (2 Replies)
Discussion started by: techshots
2 Replies

9. Shell Programming and Scripting

how to invoke shell script

hi everybody, i learning unix now only.Can u pls guide me in invoking a shell script.Actually i need to know how to write the command for invoking the shell script.Suppose the shell file name is count , then how i will write the command. thanks (1 Reply)
Discussion started by: gopa_mani
1 Replies

10. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Login or Register to Ask a Question