RunTime.getRunTime().Exec()

Hi All,

I am trying to trigger a VB script through a Java program.

I am able to trigger the script by using 'RunTime.getRunTime().Exec(commands)'. commands are the arguments which I am passing it to the script.

My requirement is whenever the VB script returns an error message on the cmd line interface, I need to capture that error message in the Java program. Is it possible?

I tried with getErrorStream, but the program is returning null.

Just I want to make sure, is it possible from the Java program to capture the error messages returned by the VB script.

A snippet of code

Process p=Runtime.getRuntime().exec(commands);

BufferedReader input =new BufferedReader (new InputStreamReader(p.getErrorStream()));

while ((line = input.readLine()) != null) {

System.out.println(line);

line = input.readLine(), it is returning null, but the VB script is throwing an error message.

Any ideas please

Thanks

[1010 byte] By [dortmund_developera] at [2007-11-27 7:35:18]
# 1
How do you know the VB script is outputting an error message?If it is sending an error message, maybe it's sending it to standard output and not standard error, for some reason.Message was edited by: paulcw
paulcwa at 2007-7-12 19:15:47 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks for the replyHow can we determine whether VB script is sending error message to Standard error stream or not. when I run the Vb script using cscript command, it is returning some value on to the console. Any ideas pleaseThanks
dortmund_developera at 2007-7-12 19:15:47 > top of Java-index,Java Essentials,Java Programming...
# 3

In a unix system you can redirect the standard error and standard output streams to different files. I don't know about MS-DOS or Windows systems.

But you could also just read both the error and output streams from the process you just exec'd.

You must read this:

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

paulcwa at 2007-7-12 19:15:47 > top of Java-index,Java Essentials,Java Programming...