ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 41155] New: - The output of sshexec can't be captured by GUI
Date Tue, 12 Dec 2006 08:13:40 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41155>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41155

           Summary: The output of sshexec can't be captured by GUI
           Product: Ant
           Version: 1.7.0RC1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: wdu@ebay.com


I construct my own GUI to run testcases written by ant scripts
I hope to redirect the output to textarea at the beginning of run and 
redirect the output back to console at the end of the run.
Those echo message and log message can be print in textarea easily but 
the output of sshexec can't be print in textarea.
My related codes are as below:

	class FilteredStream extends FilterOutputStream {
	    public FilteredStream(OutputStream aStream) {
		  	super(aStream);
		}
		
		public void write(byte b[]) throws IOException {
		   String aString = new String(b);
		   postInfo(aString);
		}

		public void write(byte b[], int off, int len) throws 
IOException {
		   String aString = new String(b , off , len);
		   postInfo(aString);
		}
	}

	private void postInfo(String message) {
		taskOutput.append(message);
		//eBARTMainPanel.getResultTextPane().append(message);
		if("\r\n".equals(message)||"\n".equals(message))
			return;
		else 
			_log.info(message.replaceAll("\n",""));
	}
	
	private void redirectOutputToTextArea(){
		PrintStream out  = 
		   new PrintStream(
			 new FilteredStream(
			   new ByteArrayOutputStream()));
		defaultPrintStream = System.out;
		System.setOut(out);
		System.setErr(out);	
	}
	
	private void redirectOutputToConsole(){
		System.setOut(defaultPrintStream);
		System.setErr(defaultPrintStream);
	}

Therefore, I debug into the source code of ant.
In class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec
line 136: 
TeeOutputStream tee = new TeeOutputStream(out, new KeepAliveOutputStream
(System.out));

and in class org.apache.tools.ant.util.KeepAliveOutputStream
it extends class java.io.FilterOutputStream but didn't implement method such 
as write(byte[] b) and write(byte[] b, int off, int len)

I believe that's why the sshexec output can't be written to the textarea.
Thanks,

-Nicholas

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message