Re: exec problems

From: Michael Schlenker (schlenk_at_uni-oldenburg.de)
Date: 05/18/04


Date: Tue, 18 May 2004 17:52:07 +0200

Murrgon wrote:
> Michael Schlenker wrote:
>
>> Actually Tcl is quite good at what you want, especially with expect
>> available, but in general the problem isn't super trivial.
>>
>> Perhaps you should take a look at tkCVS to get a hint how it is done
>> correctly:
>> http://wiki.tcl.tk/tkcvs
>
>
> Well, I took a look at tkcvs and I'd have to say that it is
> fairly elaborate. It was difficult to track down exactly
> where they were running the cvs commands but I found this
> section in the exec.tcl source file:
>
> set procout [open "| $command 2>@$procerr" r]
> set procid [pid $procout]
>
> fileevent $procout readable [list \
> [namespace current]::out_handler $viewer $filter]
> flush $procerr
> fileevent $procerr readable [list [namespace current]::err_handler]
>
> vwait [namespace current]::ExecDone
>
> If I understand this correctly (and I'm not sure that I do), they
> are using 'open' to exectute the CVS command and using 'fileevent'
> to watch for and handle the output from the command. This seems
> way more complicated than it needs to be.
This is a typical pipe setup for tcl (rather complex looking due to the
[namespace] and [list] quoting they do).

If you just want to exec a cvs command like cvs update and do not need
to have a user enter data interactivly to the program this is total
overkill. The big benefit of this is that you can display data as it
gets output by cvs and do not experience hangs of your GUI, not only
when the whole command has finished. And you would in principle be able
to feed input into the command. (not done in the above setting, so you
may have found the typical cvs invocation, but not the login.)

Could be that you simply want bgexec from the BLT package.

> I may end up switching
> to Python if this ends up being more trouble than it's worth.
How does using Python make this any easier (unless you know Python well
already and do not know Tcl)?

Michael



Relevant Pages

  • Re: how do you get a handle to the interpreter?
    ... Michael Schlenker wrote: ... >> launch it from the tcl script via exec, rather than creating it as a tcl ... >> made into a command ... etc) you could build a custom tclsh/wish. ...
    (comp.lang.tcl)
  • Re: exec problems
    ... > This is a typical pipe setup for tcl (rather complex looking due to the ... > If you just want to exec a cvs command like cvs update and do not need ... > when the whole command has finished. ... >> to Python if this ends up being more trouble than it's worth. ...
    (comp.lang.tcl)
  • Re: setting env(CVSROOT) doesnt work (was Re: How do I do setenv inside TCL Expect?)
    ... If anyone uses CVS to check in / check out files, ... Well, in my TCL script, I did "set env...." ... Also, if you do this in a script, run the script, and then run the cvs ... It *won't* work if you're doing it like this from the command line: ...
    (comp.lang.tcl)
  • Re: 3Dcanvas error
    ... I used the following command to get the 3dcanvas sources (I'm not used ... to cvs at all): ... (I found this address on the tcl wiki). ...
    (comp.lang.tcl)
  • ANN: AOLserver 4.5.0 released!
    ... On behalf of the AOLserver Team, I have the honor of announcing the ... AOLserver 4.5.0 is a major upgrade including several new Tcl commands, ... AOLserver is America Online's Open-Source web server. ... the "ns_zlib" command for compressing and uncompressing ...
    (comp.lang.tcl)