[tcljava-user] HELP...Calling TCL scripts from a Java program
Brought to you by:
mdejong
From: Tam H. <th...@su...> - 2001-05-11 00:41:25
|
I'm trying to execute a Tcl script from a java program using the java Runtime class. However, the script does not execute because my log file is never created. Should i stick to this Runtime class or use something like Tcl blend to include a class to call the script. I'm just trying to find the quickest solution to call the script, pass it parameters, and get results from the script in return..Am i even calling the script the right way? Any suggestions would be appreciated!! TCL SCRIPT: set f "log.txt" set out [open $f w] puts $out $argv0 puts $out $argv1 puts $out $argv2 close $out JAVA PROGRAM: public static void main(String args[]) { try { String s; String[] argv = {"hey", "there", "buddy"}; String[] cmd = new String[2]; cmd[0] = "d:\\Tcl83\\bin\\wish83.exe"; cmd[1] = "d:\\cygwin\\bin\\hello.tcl"; Process myProcess = Runtime.getRuntime().exec(cmd, argv); myProcess.waitFor(); System.out.println("Process exit code is: " + myProcess.exitValue()); DataInputStream in = new DataInputStream(myProcess.getInputStream()); while ((s = in.readLine()) != null) { System.out.println(s); } } catch (Throwable t) { System.err.println(t); t.printStackTrace(); //Ensure the application exits with an error condition. System.exit(1); } } |