I have a problem that I am stumped with. I am trying to write a java
application using NetRexx that allows the user to issue a command, have that
command run on a particular system and have the output returned to stdout.
The code I am including has two subtle problems. First, when I issue a
command it appears to go into an endless wait loop waiting for null. For
some reason it can not detect that the output of the command is completed.
Secondly I am running this on a Windows95 platform and I can only seem to
run .bat files from which I have then to execute the .exe that I really want
to run directly. I am not sure but it appears to be an internal program
error with the way null is being handled. I have reviewed several other
samples of trying to do similar processing but with no success.
Can you please provde me some input to this problem? I would greatly
appreciate the push over the hill so I can get going again on my own.
Thanks!
/* chkdir.nrx */
parse arg cmd .
do
child = Runtime.getRuntime().exec(cmd) -- program start
-- read input from child process
in = BufferedReader(InputStreamReader(child.getInputStream()))
line = in.readline
loop while line \= null
say line
line = in.readline()
end
-- wait for exit of child process and check return code
child.waitFor()
if child.exitValue() \= 0 then
say cmd ' return code' child.exitValue()
catch IOException
say 'Sorry cannot find' cmd
catch e2=InterruptedException
e2.printStackTrace()
end
<<RUNCMD.NRX>> <<RUNCMD~1.CLA>>