So I'm using the coproc command in a script to run a java program and to feed input to it, as follows:
#!/bin/bash
echo Script started.
coproc java -jar MultiThreadedFileProcessor.jar
echo start >&${COPROC[1]}
echo Script terminated.
I'd like to be able to write another script which can pass more input to this program (e.g. a command which will tell the program to run termination routines).
Is there any way that I can access the stdin of the coprocess from another script? My current attempt at a termination script is as follows:
#!/bin/bash
echo Script started.
echo terminate >&${COPROC[1]}
echo close >&${COPROC[1]}
echo Script terminated.
This gives me an ambiguous redirect
error however, I'm guessing because COPROC[1] is only defined in the script that creates the coproc.
How else, if at all, can I write a script that will accomplish my goal of passing a line to the java program?