From: Kent B. <ke...@er...> - 2002-10-03 15:40:15
|
The OpenSource Erlang development environment uses wish as an back-end for graphics. The front-end written in Erlang send commands over pipes or a socket to wish and wish send response back to Erlang as text over the same pipes or socket. We use pipes on Unix and socket on Windows. I try to port the Erlang graphic handling to MacOS X but have some problems. First I can't figure out how to pipe things to the "Wish Shell". It works on other Unix platforms but not on MacOS X. The Tcl script that read from the pipe looks like fconfigure stdin -buffering line -blocking 0 fileevent stdin readable main_reader proc main_reader {} { global command if {[gets stdin line] < 0} { if {[eof stdin]} { catch {close stdin} exit } } else { # We may read command with strings spanning # multiple lines so we put back the \n that # gets took away. [Is this true or even possible?] append command $line "\n" if [info complete $command] { # puts stderr "MSG $command EOMSG\r" if [catch {uplevel #0 $command} msg] { # FIXME add \r to \n puts stderr $msg } else { puts -nonewline stdout $msg } set command "" } } } [comments about how to code this better is welcome, I'm not a Tcl programmer] A slightly different socket version of this code that talk over localhost between Erlang and wish works but hopefully I will gain some performance using pipes. I use the released 8.4.0 TAR ball to build wish. Do you know any limitations in the MacOS X version when it comes to reading and writing to another process over pipes? The "Wish Shell" seem to be more oriented as a true MacOS GUI application than a traditional XWindows application. Is it more natural to call this script using "open myscript.tcl" than trying to find the absolute path to the executable? If so, I can't use pipes can I? Something like % cat test-commands.tcl | open cmd-reader.tcl kent http://www.erlang.org/download/snapshots/ |