[tcljava-user] How does java interact with tcl?
Brought to you by:
mdejong
From: mallick c. <mal...@ya...> - 2008-07-07 03:36:50
|
Hi , We have rewritten the tcl.lang.Shell to our need , so it works for us. The in/out streams are by default STDIN and STDOUT which does not solve our requirement , so we have written a simple client (reads/writes) in socket . the stdin and stdout is replaced with socket input stream and output stream. hope this helps Mallick ----- Original Message ---- From: "tcl...@li..." <tcl...@li...> To: tcl...@li... Sent: Sunday, June 15, 2008 12:39:32 AM Subject: tcljava-user Digest, Vol 23, Issue 4 Send tcljava-user mailing list submissions to tcl...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/tcljava-user or, via email, send a message with subject or body 'help' to tcl...@li... You can reach the person managing the list at tcl...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of tcljava-user digest..." Today's Topics: 1. Q. How does java interact with tcl? (Kim,Younghun) ---------------------------------------------------------------------- Message: 1 Date: Sat, 14 Jun 2008 11:52:01 +0900 From: "Kim,Younghun" <mys...@ic...> Subject: [tcljava-user] Q. How does java interact with tcl? To: <tcl...@li...> Message-ID: <000401c8cdc9$9eb4f8c0$dc1eea40$@ac.kr> Content-Type: text/plain; charset="us-ascii" Hello dear , First at all, I'm not sure my question is proper or not to this topic. But, I'm considering I should use Tcljava. Because I ask to here. I'm doing a project. In this project I'm making simple java program which can interact with "tclsh". Java program is designed originally without tclblend and jacl. In my idea, java can call the "tclsh" by using 'ProcessBuilder' class. It then gets input/error/ouput-streams of tclsh. If I handle these three-stream, I may be able to handle tclsh through java-program.(sample source code is attached below) This is my idea but, it doesn't work. I think I couldn't get these streams. Anyway while processbuilder are handling tclsh, tclsh process is working on system. I guess tclsh, I guess this is a kind of shell, uses own shell, so java cannot intercept IO streams of it. How do you think of this problem? Is there any solution? or If do I use the TclBlend, can I obtain way to solve this problem? If you have any experience or comment, please let me know. I'm working with: Tcl version is ActiveTcl 8.4. I'm using java sdk 6 And I tried test based on windows and linux both. Thank you. Best regards import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class TclExcuter { public Process oProcess; BufferedReader reader; BufferedWriter writer; public TclExcuter(String[] args) { } public TclExcuter(String args) { } public TclExcuter() { this.runTcl(); } private String runTcl() { String result = ""; String tmp; try { /* over the java version 1.5 */ ProcessBuilder pb =new ProcessBuilder("cmd","/y","/c","tclsh"); pb = pb.directory(new File("C:\\")); pb = pb.redirectErrorStream(true); oProcess = pb.start(); reader = new BufferedReader(new InputStreamReader(oProcess.getInputStream())); writer = new BufferedWriter(new OutputStreamWriter(oProcess.getOutputStream())); } catch (IOException e) { e.printStackTrace(); } return result; } public BufferedReader getReader() { return reader; } public BufferedWriter getWriter() { return writer; } } -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ------------------------------ _______________________________________________ tcljava-user mailing list tcl...@li... https://lists.sourceforge.net/lists/listinfo/tcljava-user End of tcljava-user Digest, Vol 23, Issue 4 ******************************************* |