Hi ... and a request
Hello all, I'm new to the group, so "hi". I have a request for information: Im currently developing a front end in Java for the SpeakFreely suite of tools. As a result, I need to be able to capture their stdout and parse it. No problems I thought - just do an exec() and get the InputStream via getInputStream() on the resulting Process instance. However; I am having no end of difficulties here. If I exec the command (which if anyone is interested goes something like sflwl -hlwl.fourmilab.ch:2076 '[EMAIL PROTECTED]') I get nothing back. However, I can stuff this into the shell, and I get back: [neil@fastspod Project]$ sflwl -hlwl.fourmilab.ch:2076 '[EMAIL PROTECTED]' 209.78.48.182:2074 [EMAIL PROTECTED] (Neil Clayton) [neil@fastspod Project]$ I changed 'sflwl' to 'echo' to test my Java program, and it is able to report the results of that fine. I've tried other unix command line utils, and they have their results processed by my Java code. I then looked into the sflwl source code, to see if it was doing anything weird with stdout. Not that I can see. I just wanted to ask if there is any known problem with the linux jvm here. Current JVM is v1.1.7v1, Ive tried 1.2 prev2 with no difference (Ive downloaded by not yet tried v1.1.7v3) Regards, Neil Clayton -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
More info on capturing stdout
Following up on my previous message, I have more information:
I've been playing with the code for sflwl, and found that something
*very weird* if happening.
This is a snippet from lwl.c.
myPrintf("While\n");
while (sdes_count-- > 0) {
struct lwl *lw;
myPrintf("In loop\n");
As expected, the output from the console looks like this:
While
In loop
209.78.48.182:2074 [EMAIL PROTECTED] (Neil Clayton)
Try again
Destorying
La1
La2
La3
(as you can see, I've stuck a number of other printf's in there too).
Weird thing is, the output from my Java program is:
While
La2
La3
So it does capture *some* stdout - but any printf statement I put
*inside* the above mentioned while loop does not come out. I am now
officially stumped :-)
I've never seen behaviour like this before! And now I can't tell if it's
anything to do with the JVM or something *weird* is hapnnening on my
linux box.
Comments and sanity checks would be welcome!
Im more than happy to send whatever code is required to anyone who
wishes to help verify the situation.
Regards,
Neil Clayton
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Fixed (capturing stdout)
Well, sorry to leave so many messages regarding this. I've worked it out - so problem is now history, and it was nothing to do with the VM. Cheers, Neil Clayton -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Capturing stdout.
Oh, thought I would provide an explanation of my problem, just so people know. The full command was: sflwl -hlwl.fourmilab.ch:2076 '[EMAIL PROTECTED]' The argument to sflwl being 1. -hlwl.fourmilab.ch:2076 2. [EMAIL PROTECTED] Which of course works fine in the shell. However; I was using the single argument form of Runtime.exec(String command), and this was passing in the quotes too. So the arguments to sflwl when run under Java were: 1. -hlwl.fourmilab.ch:2076 2. '[EMAIL PROTECTED]' And of course the command failed to produce any output, because no one with that email address existed on the server (must be an exact match). I had actually tried the array version, exec(String cmd[]), but that failed to produce the right output since the args to sflwl became (it appears to perform a splilt on the ':'): 1. -hlwl.fourmilab.ch 2. 2076 3. [EMAIL PROTECTED] Anyway, so there is my solution. As I emailed to some other kind person who was attemptin to help me: Live and learn. So this must mean that the VM does not use the *nix shell in order to exec() commands? (forgive the question, I've not looked at the JVM source) Neil -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
