I have two .jar file in a pipeline. 1.jar will output two lines, both of which will be the input of 2.jar. Now I want to store the each line of the intermediate output of 1.jar to variables A and B, while allowing 2.jar to take both lines as input.
java -jar 1.jar | XXX | java -jar 2.jar
As a detour, I could do
java -jar 1.jar | tee out | java -jar 2.jar
and read the file to save the variables, but I'd like a more straight-forward way of doing it.
There really isn't going to be a straight-forward way to do it. One of the problems is that any variable setting in the middle of a pipeline only affects that process in the pipeline, not the main shell. You might be able to contrive something with multiple file descriptors and process substitution and so on, but it will not be straight-forward.
No comments:
Post a Comment