Re: [tcljava-user] HELP...Calling TCL scripts from a Java program
Brought to you by:
mdejong
From: D. J. H. <dha...@mi...> - 2001-05-12 03:08:47
|
The fundamental problem here is that Runtime.exec(...) is a very primitive interface and hard to use correctly, especially to capture large chunks of output from stdout/stderr or input large chunks of data to stdin. The following article on JavaWorld provides a good example at the end: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html I don't know if this "fix" has yet been applied to Jacl's exec, per Mo's reply, but I was intending to do so someday if someone hasn't already... In addition, you should really use a BufferedReader(InputStreamReader()) chain around the exec'd process output if you want to capture text lines. DataInputStream is for binary struct-type and serialized Java object data, not text. -=- D. J. Tam Huynh wrote: > 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? [ . . . ] > Process myProcess = Runtime.getRuntime().exec(cmd, argv); > myProcess.waitFor(); > System.out.println("Process exit code is: " + > myProcess.exitValue()); > > DataInputStream in = new > DataInputStream(myProcess.getInputStream()); [ . . . ] |