开发者

Procmail recipe, pipe to Java stdin

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 bufRea开发者_开发技巧der = 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?


remove the quotation marks around "/usr/bin/java -cp /root/parser HelloWorldApp".

source: http://www.linfo.org/pipe.html


The "filter" flag on your recipe specifies that the pipeline will read a message on standard input and write back a (possibly not altered) message on standard output, which will replace the original message.

As Jake223 already replied, the quotation marks around the command are incorrect, and should be removed. The error message doesn't really look like it corresponds to that particular error, though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜