Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JACL - redirection of std* channels

27 views
Skip to first unread message

Sektor van Skijlen

unread,
Feb 25, 2008, 10:52:50 AM2/25/08
to
`lo,

I have an application that uses Tcl-based (standalone) application by just
executing the tclsh with channel two-way redirection.

As now this application is in Java, I would like to use Jacl to perform the
job of interpreting the Tcl scripts.

My first idea was to replace the "Runtime.getRuntime().exec(...)" with Jacl's
Interp.evalFile(). However, how would I redirect channels?

The Tcl script is desitned as a console application that communicates with
stdin/stdout. I need that it be possible to run this, even in a separate
thread, but in such a form that the data written to stdout in this Tcl
application are being able to be read by the Java application that spawns it.

Is it possible?


--
// _ ___ Michal "Sektor" Malecki <sektor(whirl)kis.p.lodz.pl>
\\ L_ |/ `| /^\ ,() <ethouris(O)gmail.com>
// \_ |\ \/ \_/ /\ C++ bez cholesterolu: http://www.intercon.pl/~sektor/cbx
"Java is answer for a question that has never been stated"

Tom Poindexter

unread,
Feb 25, 2008, 5:50:35 PM2/25/08
to
In article <fpuo8i$58g$1...@kujawiak.man.lodz.pl>,

Sektor van Skijlen <etho...@guess.if.gmail.com.is.valid.or.invalid> wrote:
>`lo,
>
>I have an application that uses Tcl-based (standalone) application by just
>executing the tclsh with channel two-way redirection.
>
>As now this application is in Java, I would like to use Jacl to perform the
>job of interpreting the Tcl scripts.
>
>My first idea was to replace the "Runtime.getRuntime().exec(...)" with Jacl's
>Interp.evalFile(). However, how would I redirect channels?
>
>The Tcl script is desitned as a console application that communicates with
>stdin/stdout. I need that it be possible to run this, even in a separate
>thread, but in such a form that the data written to stdout in this Tcl
>application are being able to be read by the Java application that spawns it.
>
>Is it possible?


Assuming you are initializing your Jacl Interp from your
own Java code, you should be able to change stdin/stdout/stderr
by invoking the following with your own InputStream and
OutputStream:

StdChannel.setIn(InputStream in)
StdChannel.setOut(PrintStream out)
StdChannel.setErr(PrintStream err)

--
Tom Poindexter
tpoi...@nyx.net

ethouris

unread,
Feb 26, 2008, 8:20:34 PM2/26/08
to
On 25 Lut, 23:50, tpoin...@nyx.net (Tom Poindexter) wrote:
> Assuming you are initializing your Jacl Interp from your
> own Java code, you should be able to change stdin/stdout/stderr
> by invoking the following with your own InputStream and
> OutputStream:
>
>     StdChannel.setIn(InputStream in)
>     StdChannel.setOut(PrintStream out)
>     StdChannel.setErr(PrintStream err)

Wow! Wonderful, but... could you tell me, what version it is and where
I can download it?

I tried Jacl version 1.4.1 found on Sourceforge, but the StdChannel
class does not have any of these methods!

Tom Poindexter

unread,
Feb 26, 2008, 10:58:21 PM2/26/08
to

Sektor van Skijlen

unread,
Feb 27, 2008, 5:31:39 AM2/27/08
to
Dnia 27 Feb 2008 03:58:21 GMT, Tom Poindexter skrobie:

> In article <6b0d84fe-1212-43a5...@s12g2000prg.googlegroups.com>,
> ethouris <etho...@gmail.com> wrote:
> >On 25 Lut, 23:50, tpoin...@nyx.net (Tom Poindexter) wrote:
> >> Assuming you are initializing your Jacl Interp from your
> >> own Java code, you should be able to change stdin/stdout/stderr
> >> by invoking the following with your own InputStream and
> >> OutputStream:
> >>
> >> ? ? StdChannel.setIn(InputStream in)
> >> ? ? StdChannel.setOut(PrintStream out)
> >> ? ? StdChannel.setErr(PrintStream err)

> >
> >Wow! Wonderful, but... could you tell me, what version it is and where
> >I can download it?
> >
> >I tried Jacl version 1.4.1 found on Sourceforge, but the StdChannel
> >class does not have any of these methods!


> This is on the CVS HEAD:

> http://tcljava.cvs.sourceforge.net/tcljava/tcljava/src/jacl/tcl/lang/StdChannel.java?revision=1.20&view=markup

> see lines 60-70. These are static methods for the class.
> ChangeLog entry at:
> http://tcljava.cvs.sourceforge.net/tcljava/tcljava/ChangeLog?revision=1.491&view=markup


And plans for the release?

I am using currently tclsh8.5 for Cygwin (manually compiled) because the
Windows version reveals some bug when Tcl is spawning an application through
[open] - deadlock on [gets] (only in combination: Java + Tclsh for
Windows - no reproduction on Linux, Cygwin and C++ version of the master
application). Using Jacl would really simplify the deployment (stating that
the Tcl-Windows version can't be used), but I would really know the release
plans for this version of Jacl before I plan anything in my project.

Tom Poindexter

unread,
Feb 27, 2008, 12:40:57 PM2/27/08
to
In article <fq3e6b$q34$1...@kujawiak.man.lodz.pl>,

Sektor van Skijlen <etho...@guess.if.gmail.com.is.valid.or.invalid> wrote:
>Dnia 27 Feb 2008 03:58:21 GMT, Tom Poindexter skrobie:
>
>And plans for the release?
>

That I don't know. Probably better to ask on the tcljava-dev mailing list,

see:
http://sourceforge.net/mail/?group_id=13005

for mailing list info.

--
Tom Poindexter
tpoi...@nyx.net

0 new messages