jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiger Patel" <jiger_...@hotmail.com>
Subject Capturing sysin and sysout
Date Wed, 04 Jun 2003 06:16:09 GMT
Hi,
    Is there someway to capture the sysout and sysin of any BSF Scripting 
engine. In my application I want to capture the output of a "print" or a 
"System.out.println" or any "console" out and show it on the GUI textarea. 
"Beanshell" and "javascript"(see note below) "seem" to be working but jython 
is playing some game. I tried redirecting System.out to a ByteArrayBuffer in 
the following way

ByteArrayOutputStream byOut = new ByteArrayOutputStream();
PrintStream  pOut = new PrintStream(byOut);
PrintStream oldStream = System.out;
System.setOut(pOut);
loadBSFManager(view);
bsfmanager.exec(bsfpanel.getCurrentLanguage(),filename,1,1,script);
pOut.flush();
printOutput(byOut.toString());
System.setOut(oldStream);
pOut.close();
pOut=null;
byOut = null;

But yet jython's "print" statement comes on the System.out logs but not in 
the byOut above. Other languages seem to work fine. Except Javascript which 
returns an org.mozilla.javascript.UndefinedFunction object in the eval but 
that is a for some other mail.

So can anyone suggest someway as to how to capture the sysouts and sysins in 
some language independent way or can BSF add Input and Output stream params 
to the exec/eval methods which the scripting engines can then enforce in the 
language dependent way. Or maybe some method like setIn and setOut in the 
BSFManager for the streams to be used by the scripting engines when they are 
initiailised.

Any ideas?

Thanking you,
Jiger.

_________________________________________________________________
Technical writer?. Earn more now! 
http://server1.msn.co.in/msnleads/tis/index.asp Find out how.


Mime
View raw message