Redirecting Windows output

This is undoubtedly the wrong place to post this, but I don't really know where else to post.

On a windows machine, from java, I run a batch file. This batch file sets up an environment for an executable, and then runs the executable. I need to capture the output of this executable. As of now, I have a method that runs a shell command and returns the output as an array of strings. It works fine. Except in this case. Since the command I execute from inside the java program is a batchfile, that then runs another executable, the output doesn't work the same. I'm guessing because I am getting the output of the thread that was created for the batch file, but when the batch file runs the exe, it is a whole new thread and thus I can't get the output.

Are there any command line or java tricks I can use to properly get the output?

Thanks

[870 byte] By [Losinga] at [2007-11-27 5:25:01]
# 1

Quick answer: no.

What you are saying in essence is that you need to capture the ourput from a process that is spawned by a process that is spawned by a process that you spawned.

Java is not aware of this complex relationship. Neither is Windows for that matter.

You would have to pipe the output back from each process in turn. That's the only solution here though it may not help you any.

cotton.ma at 2007-7-12 14:44:50 > top of Java-index,Java Essentials,Java Programming...
# 2

> On a windows machine, from java, I run a batch file.

> This batch file sets up an environment for an

> executable, and then runs the executable. I need to

> capture the output of this executable. As of now, I

> have a method that runs a shell command and returns

> the output as an array of strings. It works fine.

> Except in this case. Since the command I execute

> from inside the java program is a batchfile, that

> then runs another executable, the output doesn't

> work the same. I'm guessing because I am getting

> the output of the thread that was created for the

> batch file, but when the batch file runs the exe, it

> is a whole new thread and thus I can't get the

> output.

Reading that was like listening to Sir Humphrey.

floundera at 2007-7-12 14:44:50 > top of Java-index,Java Essentials,Java Programming...
# 3
> > Reading that was like listening to Sir Humphrey.Who or what is Sir Humphrey?
cotton.ma at 2007-7-12 14:44:50 > top of Java-index,Java Essentials,Java Programming...
# 4
I am assuming he was referring to this: http://en.wikipedia.org/wiki/Sir_Humphrey
Navy_Codera at 2007-7-12 14:44:50 > top of Java-index,Java Essentials,Java Programming...
# 5

Sir Humphrey was a character on the British policitcal satire show called Yes, Minister (later Yes, Prime Minister) who was famous for double speak. It's not the best example but one I found with a quick search.

Well, it's clear that the committee has agreed that your new policy is a really excellent plan but in view of some of the doubts being expressed, may I propose that I recall that after careful consideration, the considered view of the committee was that while they considered that the proposal met with broad approval in principle, that some of the principles were sufficiently fundamental in principle and some of the considerations so complex and finely balanced in practice, that, in principle, it was proposed that the sensible and prudent practice would be to submit the proposal for more detailed consideration, laying stress on the essential continuity of the new proposal with existing principles, and the principle of the principle arguments which the proposal proposes and propounds for their approval, in principle.

floundera at 2007-7-12 14:44:50 > top of Java-index,Java Essentials,Java Programming...
# 6
> Sir Humphrey was a character on the British> policitcal satire show called Yes, Minister (later> Yes, Prime Minister) who was famous for double speak.Ah. So like the person(s) who post into http://forum.java.sun.com/forum.jspa?forumID=515
cotton.ma at 2007-7-12 14:44:50 > top of Java-index,Java Essentials,Java Programming...