in reply to Re^4: Running perl from java
in thread Running perl from java
I strongly suggest you post the exact code you ran if you want further help. There are a million times I think I'm doing something "verbatim" and I'm not actually doing so. But whatever issue is at play, it is highly unlikely to be some sort of wierd behavior on the part of the Perl interpreter.
Some older DOS programs used to do odd things like dumping output to the console/tty rather than to STDOUT. However, to the best of my knowledge, Perl processes code snippets passed in via the "-e" parameter, exactly the same way as it does code loaded from scripts. Both send output to STDOUT, not to a physical device like a console. So the problem has to be either with the arguments you are passing to the perl command or with the java code trying to read from STDOUT.
I suppose, if you have any concerns about whether or not the -e option really sends output to standard out, you could open up a DOS shell and try piping the output of perl -e to the DOS more command or some other DOS command. However, if you can pipe the output on the command line, then the problem isn't with Perl but with the Java code.
What did you get for an exit code? Did you check the output to STDERR for any messages? Perhaps that could give you a clue about bad inputs. Also, if your code is part of a running program rather than "main" like mine, you should add a catch clause for that IOException and not just have your Java method throw it. Otherwise you'll never know if you got an IOException. If you get an IOException you'll never reach the lines responsible for extracting the Perl command output. Hence no output. (the IOException is thrown by the lines after the first try...catch)
As for dealing with timing problems catching the output from an exec'd process, if the code above didn't work, I'm at a loss. I suggest you google/search Java forums for other evidence of problems with Java programs reading the standard out stream of exec'd processes on WIndows platforms. All I can say is that I had no difficulties on a Debian Linux platform running Java 1.6.0_07.
Sorry I can't be more help.
Update: added comments about the importance of catching the IOException.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Running perl from java
by Anonymous Monk on Jan 09, 2011 at 12:13 UTC | |
by ELISHEVA (Prior) on Jan 09, 2011 at 14:51 UTC | |
by Anonymous Monk on Jan 10, 2011 at 01:44 UTC | |
by abramia (Novice) on Jan 09, 2011 at 12:36 UTC | |
by Anonymous Monk on Jan 09, 2011 at 13:43 UTC | |
|
Re^6: Running perl from java
by abramia (Novice) on Jan 09, 2011 at 12:28 UTC | |
by ELISHEVA (Prior) on Jan 09, 2011 at 13:48 UTC | |
by abramia (Novice) on Jan 09, 2011 at 14:22 UTC | |
by Anonymous Monk on Jan 09, 2011 at 14:40 UTC | |
by ELISHEVA (Prior) on Jan 09, 2011 at 15:43 UTC |