tcl/TK question

Tom Buskey tom at buskey.name
Thu Jun 30 13:37:40 EDT 2011


Take a look at the expect extension for tcl/Tk.  It was created expressly
for dealing with interactive programs.

On Thu, Jun 30, 2011 at 1:31 PM, Brian St. Pierre <brian at bstpierre.org>wrote:

> On Thu, Jun 16, 2011 at 12:41 PM, Jerry Feldman <gaf at gapps.blu.org> wrote:
> > One possible solution that seems to work. In my wrapper script:
> > <command> --arg1 --arg2.... 2>&1
> >
> > And in the tcl script:
> >
> > if [catch {open "|$command"} input] {
> >
> > I still get my zombie on the start command, but I query the open file
> list in tcl (file channels) and close any open files other than stdxxx.
> >
> > It's fun trying to write production code when you don't know the language
> :-)
>
> The section in the man page for open called COMMAND PIPELINES doesn't
> really spell it out. The `open` command returns a file descriptor. You
> need to close that file descriptor to wait for the process. Here's a
> quick demo:
>
> #!/usr/bin/tclsh
>
> # This produces a zombie, the file descriptor is "lost".
> if [catch {open "|echo foo"} input] {
>   puts "something went wrong: $input"
> }
>
> puts "Press ctrl-z now and do a ps to check for zombies"
> after 3000
>
> # This does not:
> if [catch {set f [open "|echo bar"]} input] {
>   puts "something else went wrong: $input"
> }
>
> # (The zombie is here.)
> puts "Press ctrl-z now and do a ps to check for zombies"
> after 3000
>
> close $f
>
> # (And now it's not.)
> puts "Press ctrl-z now and do a ps to check for zombies"
> after 3000
>
> # Closing the file descriptor from this `open` will cause an error.
> # (See the man page.)
> if [catch {set f [open "|/bin/false"]} input] {
>   puts "something different went wrong: $input"
> }
>
> close $f
>
> HTH.
>
> --
> Brian St. Pierre
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20110630/fda5805d/attachment.html 


More information about the gnhlug-discuss mailing list