[tcljava-user] [Tcl Java] Help Request - repost WithOut the HTML, my apologie
Brought to you by:
mdejong
From: Cliff R. <cl...@el...> - 2001-03-05 17:41:26
|
Hello: I looked at a similar request in the archives [30Oct2000] and I am have trouble getting any output back from the tcl script. Using the modified sample suggested by Mo DeJong. I am able to get an output returned from the simple tcl script when called by CallTcl.java. myTest.tcl returns a value to the java program when it contains: //myTest.tcl return [exec date] exit0; But it hangs when I try: //mytest.tcl return [exec xclock \&] exit0; It never returns... What I'm trying to learn is, how to return a process ID of an app launched by tcl to java. The original expect script spawned a shell process that returned the process of the spawned shell. From there, I used ps -s to get the process id of the java process launched by the shell. I want to later kill that java process started by the shell. I get, pipe not supported exception message when I tried: if [catch {open "|$command }] So I'm experimenting... execute the expect script and get the return, but it also hangs. Figure out how to change the script to tcl with out using open pipe. So I am using the xclock to fiddle with how to get the process ID with out hanging. I am using: tcl8.3.2 from TclPro1.5 (solaris-sparc) jacl1.2.6 and tclBlend1.2.6 for this exercise... thanks in advance and then-some :-) Cliff // learning sample that executes the tcl script that returns a process id import tcl.lang.*; public class CallTcl { Interp interp = new Interp(); public String evalScript( String s ) throws TclException { interp.eval( "source " + s ); System.out.println("-> " + interp.getResult().toString() ); return interp.getResult().toString(); } public static void main( String args[] ) throws Exception { CallTcl callTcl = new CallTcl(); String cmd = "myTest.tcl"; try { callTcl.evalScript( cmd ); } catch ( TclException te ) { te.printStackTrace(); } callTcl.interp.dispose(); } } // this was the origional expect script I'm trying to convert to tcl #! /opt/ajuba/TclPro1.5/solaris-sparc/bin/expect -- global spawn_id env set web_start $env(MISC_SHELLPATH)/bin/start.sh set web_id [spawn -noecho $web_start] set spawn_id $spawn_id sleep 2 set buf01 [exec ps -s$web_id] set jindex [lsearch $buf01 "java"] set wl_pid [lindex $buf01 [expr $jindex - 3]] return $wl_pid |