Reputation: 564
I have a JAVA-Jar-File which is provided by a third-party-dev. The File reads from STDIN and writes to STDOUT.
I was able to configure the JAR-File to write to a log file instead.
But I also have to rewrite the input-source from STDIN to a named pipe, so I can send commands to the java-pocess via my own application.
I already tried this two things to read from the pipeline (bash):
cat < pipeline_name | java -jar external_application.jar
This works fine for the first command. After receiving the first input line, the 'cat' terminates and I am not able so send commands afterwards.
My other try:
tail -f pipeline_name | java -jar external_application.jar
This works fine. All commands are passed to the JAVA-Application. BUT: If the java-application is terminating, the tail -f will run like before.
I need a solution where reading from the pipe is stopped if the JAVA-Process is terminating.
Thanks a lot
Upvotes: 0
Views: 1557
Reputation: 3629
use bash redirection and heres a cheatsheet
java -jar external_application.jar < pipeline_name
the < means the java process will read it's stdin from pipeline_name
Upvotes: 1