CROSSPOST: can't get output from IProcess [message #17045] |
Thu, 08 May 2003 02:18 |
Eclipse User |
|
|
|
I want to use the launching framework to integrate an external tool (a
change control tool like cvs) into eclipse.
The code that does the launch is appended.
The launch itself works but the problem is, that I don't get the output of
the process through the Steamsproxy, it's empty even if I see the output
of the launch on the eclipse console.
Does anybody know where I am wrong?
Thanks,
Lars
public static String invokeCMCommand(String command) throws Exception {
//TODO: Eclipse Launch-Framework benutzen (org.eclipse.debug.core)
System.out.println(command);
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type =
manager.getLaunchConfigurationType(
IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE) ;
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, "Launch");
wc.setAttribute(
IExternalToolConstants.ATTR_LOCATION,
"C:\\WINDOWS\\system32\\cmd.exe");
wc.setAttribute(
IExternalToolConstants.ATTR_TOOL_ARGUMENTS,
"/c " + command);
wc.setAttribute(IExternalToolConstants.ATTR_CAPTURE_OUTPUT, "true");
wc.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, "true");
ILaunchConfiguration config = wc.doSave();
ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
IProcess[] processes = launch.getProcesses();
System.out.println("Prozesse am laufen: " + processes.length);
StringBuffer stdOut = new StringBuffer();
StringBuffer stdErr = new StringBuffer();
for (int i = 0; i < processes.length; i++) {
IStreamsProxy streamsProxy = processes[i].getStreamsProxy();
IStreamMonitor stdOutMonitor = streamsProxy.getOutputStreamMonitor();
IStreamMonitor stdErrMonitor = streamsProxy.getErrorStreamMonitor();
stdOut.append(stdOutMonitor.getContents());
stdErr.append(stdErrMonitor.getContents());
}
System.out.println("stdOut: " + stdOut);
System.out.println("stdErr: " + stdErr);
return stdOut.toString();
}
|
|
|
Powered by
FUDForum. Page generated in 0.24154 seconds