Run a script based on the subject line of the email
I need help in running a script that would pull info from an email subject line and run a script (foo.sh). I'm pretty sure after a bit of googling that this is possible in several ways. but none was pretty clear on how to accomplish it. The part that I really need help with is getting the info from the email subject and pass it to the script as parameter. I am also considering perl as an option and would use perl if advised.
Basically i get emails with a standard subject line saying:
and i am planning to create a script dojob.sh job1 copy1.
i am typically looking for some way to accomplish this. i am pretty much new to unix (i am now in charge of some processes in HP-unx and AIX). I need to get these done in order to save my job. Typically whoever was in this position before were fired failing to accomplish this. I hope somebody will help me save my job here.
You probably need to spec this a bit better.
It's not clear whether you need help with writing the "dojob.sh" script,
or with taking the subject line and using the information in it to invoke
the command "dojob.sh job1 copy1"
...which you could pipe to a shell to get it executed.
Curious people might want to know whether you have some way of intercepting
the emails and processing them automatically as they come in,
or if you plan to do this manually with copy/paste and your email client (for example).
i am trying to accomplish reding the subject line of the email and parsing the parameter to the script which i am creating to do the job.
The point is to run the script as soon as the email arrives.
Email: Sub: Dojob param1=ABC param2 = 3
i need a way to run the script like this. myscript.sh ABC 3.
Note: i already have the script which is run manually after reading the mail . I have to type the parameters and run it every single time. I now want a way or a program that can read this email subject(which has a fixed format) and run the script automatically.
in perl you have to use mail parser for this which will give you exact subject
i have worked on such kind of application which used to read mails then depending upon the mail contents it used to do the job. but for that there were some standards used you have to do the same.
i am a complete idiot when it comes to these standards or unix, but i can learn real quick as long it is a Programming language. So can you please make available your above mentioned stuff. it will be very useful.