Re: Problem in calling c programs and compiling them in tcl/tk
- From: Alexandre Ferrieux <alexandre.ferrieux@xxxxxxxxx>
- Date: Wed, 12 Nov 2008 01:39:04 -0800 (PST)
On Nov 12, 10:16 am, vasavi.n...@xxxxxxxxx wrote:
I got a doubt. Let's say am compiling a prime.c program that
requires user i/p. Now, if I write like
exec gcc -o prime prime.c
First, please take into account what was said earlier. You should
really do
exec gcc -o prime prime.c 2>@ stderr
This way, even if gcc emits warnings, you'll just see them without
generating a Tcl error.
and later as ,
exec ./prime
then in the terminal it's waiting 4r user to enter the i/p number.
Later only it's printing [the prompt]
That's a second redirection gotcha :-)
Indeed, [exec] tries to get back the output from the command into a
usable result, so that you can write
set res [exec foo ...]
For this, it doesn't let the output just go to the terminal, it sets
up a pipe for the child to write into, and accumulates whatever comes
down, until the child dies, at which point the accumulated result is
available (and displayed in an interactive session).
Now if you really want the output to go directly to the terminal (but
in that case Tcl will not see it... so its interplay with the child
will be limited ;-), just do a redirection: >@ stdout .
Summing up, this yields:
exec ./prime >@ stdout 2>@ stderr
In case you wonder, that's it. Stdin is already inherited from parent
by default.
-Alex
.
- Follow-Ups:
- Re: Problem in calling c programs and compiling them in tcl/tk
- From: vasavi . naga
- Re: Problem in calling c programs and compiling them in tcl/tk
- References:
- Problem in calling c programs and compiling them in tcl/tk
- From: vasavi . naga
- Re: Problem in calling c programs and compiling them in tcl/tk
- From: Alexandre Ferrieux
- Re: Problem in calling c programs and compiling them in tcl/tk
- From: Neil Madden
- Re: Problem in calling c programs and compiling them in tcl/tk
- From: Alexandre Ferrieux
- Re: Problem in calling c programs and compiling them in tcl/tk
- From: Neil Madden
- Re: Problem in calling c programs and compiling them in tcl/tk
- From: Alexandre Ferrieux
- Re: Problem in calling c programs and compiling them in tcl/tk
- From: vasavi . naga
- Problem in calling c programs and compiling them in tcl/tk
- Prev by Date: Re: Problem in calling c programs and compiling them in tcl/tk
- Next by Date: Re: Tcl script for creating folders on multiple remote servers from local machines and transfer files to those servers into created folder
- Previous by thread: Re: Problem in calling c programs and compiling them in tcl/tk
- Next by thread: Re: Problem in calling c programs and compiling them in tcl/tk
- Index(es):
Relevant Pages
|