For the software package I am working on, I use the Stanford Natural Language Parser. The parser can be ran by calling a Linux shell command which looks like this:
$ bash lexparser.sh input.txt
The parser then loads the parser and parses the sentences found in input.txt. The loading of the parser, however, takes about 4 seconds. Another possibility is:
$ bash lexparser.sh -
Using this function, the parser is loaded and waits for input, which can than be directly typed into the terminal.
Because the program I am creating needs to work in less than 4 seconds, I want to use the second option. Has anyone got any idea how to give the terminal input while allready running an executable in that terminal?
Well, my program needs to wait for input and when given, it needs to run the given sentence in the parser. So, when the parser is allready loaded, it can give output faster. That's why I want to use the second option.
Still, I don't think this is the right approach, because the parser needs to be loaded and running, waiting for input.
Right now, I use the first approach in my program, with popen. This runs the command given, gives the output and than stops, but I need to run a command which runs an executable and later on give more input to the same terminal.
For this, I think the boost.process library is suitable.
The reason it sometimes takes as long as four seconds to run is because it's Java. That time is the time it takes the JVM to load. No clever scripting or wrapping with BASH or C++ is going to fix that.