I'm trying to run some custom parsing on incoming mail using procmail, and would like to call a java program to read in the headers and body of the message using the |pipe to stdin. There are plenty of examples of having your mail filtered using perl, and python, but none using java. As a starting example, my procmail recipe:
:0 hbfW
|"/usr/bin/java -cp /root/parser HelloWorldApp"
And my java app just echo's stdin:
import java.io.*;
public class HelloWorldApp {
public static void main(String[] args) {
InputStreamReader isReader = new InputStreamReader(System.in);
BufferedReader bufReader = new BufferedReader(isReader);
while(true){
try {
String inputStr = null;
if((inputStr=bufReader.readLine()) != null) {
System.out.println(inputStr);
}
else {
break;
}
}
catch (Exception e) {
break;
}
}
}
}
procmail log:
procmail: Executing "/usr/bin/java -cp /root/parser HelloWorldApp"
/bin/sh: /usr/bin/java HelloWorldApp: No such file or directory
procmail: Error while writing to "/usr/bin/java HelloWorldApp"
procmail: Rescue of unfiltered data succeeded
1) Am I creating the right recipie to pipe the data to java? 2) Since I still want procmail to handle delivery, my recipe using the (f) flag. But how to I have the result created from my java program sent back to procmail? stdout?