0

For a university project I need to verify a huge amount of data (~ 5TB) with zlint. I tried to create a file for each certificate and redirect the contents with ./zlint temp-cert.pem -format pem but as the data set is huge this approach is too slow.

The external program zlint is able to read from stdin or from a file.

Currently I iterate through the set and execute for each line:

Runtime rt = Runtime.getRuntime();
String[] cmd = new String[] {"echo \"" + dao.raw + "\" | zlint -format base64"};
Process pr = rt.exec(cmd);
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
while ((line = input.readLine()) != null) {
    cmdOutput.append(line);
}
// handle the results

Using this command works very well for the command-line. For the Java-runtime I get:

Cannot run program "echo "..." | ./zlint -format base64": error=63, File name too long
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:620)
    at java.lang.Runtime.exec(Runtime.java:485)
    ...
Caused by: java.io.IOException: error=63, File name too long
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 6 more

Is there any approach where I can pipe the raw text to the external program without the need of creating a temporary file?

barfoos
  • 706
  • 2
  • 12
  • 26
  • There are several possible arguments you can pass as command parts, and for good reason. Java process builder is **not** the same as a command line: you have to pass the command line interpreter executable as the first string for the new process command, and arguments to that as the rest. – M. Prokhorov Apr 16 '18 at 13:36
  • 3
    Possible duplicate of [How to make pipes work with Runtime.exec()?](https://stackoverflow.com/questions/5928225/how-to-make-pipes-work-with-runtime-exec) – Nikolai Shevchenko Apr 16 '18 at 13:38

0 Answers0