Calling all Gurus. . .
Here is my problem.
I have two C/C++ executables that I want to be able to make calls to from Runtime.exec() on Redhat linux.
I don't know much about their inner workings, but running them from the command line you give the executables two arguments; an input file and an output file. The programs do there stuff with a few messages coming back to standard output and the results should goto the output files. Both executables run fine from the command line.
Here is where the hell starts. . .
I make my little
String cmd[] and line up the arguments in a nice little package and feed it to Runtime.exec(). One of the programs does what it is supposed to with one small oddity, input file goes in, output file comes out, mostly as expected.
Though the programs have identical formats for running from the command line, the other program does not behave. The output file specified is a blank file, the process.getInputStream() does not give anything back, and the process returns an exitValue() of 0.
Both the programs run perfect from the command line, and both take nearly identical input format to run. Initially I thought the problem might have something to do with the fact that I was trying to use the Runtime.exec from a
servlet container (
Tomcat), but then I wrote a
test class that tries to run the programs from a "normal"
java application. Same results. (Here was where I found an oddity with the first program, in the test class the getInputStream is giving me all the output from standard output, but in the
JSP, I only get the last line. It might have something to do with buffered writers, but I don't really care as I am primarily interested in the contents of the output files.) The one program runs great, the other one doesn't. Same behavior, empty file, exitValue = 0.
The programmer that wrote them doesn't know what might be different between the two programs that would cause this, and I have been beating myself senseless trying to figure it out.
If anyone has any clue that can stop my madness, please offer it.
That's what I'm doing for both, with the filenames dynamically determined, but I get the same behavior when I hard code the filenames.