Re: Problem in calling c programs and compiling them in tcl/tk



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
.



Relevant Pages

  • Re: g77 & gcc problem
    ... gcc: installation problem, cannot exec `f771': No such file or ... gcc: anal.inc: linker input file unused because linking not done ...
    (comp.lang.fortran)
  • g77 & gcc problem
    ... gcc: installation problem, cannot exec `f771': No such file or ... gcc: anal.inc: linker input file unused because linking not done ...
    (comp.lang.fortran)
  • Re: Problem in calling c programs and compiling them in tcl/tk
    ... using exec gcc filename.c and later exec ./a.out filename.c. ... the execution of a command that might generate a Tcl error. ... saying "any time I see this, ... The important thing is if i try to run the same using gcc helloworld.c ...
    (comp.lang.tcl)
  • Re: Trouble Using Asis Tools
    ... gcc: error trying to exec 'gnat1': execvp: No such file or directory ...
    (comp.lang.ada)
  • Re: Trouble Using Asis Tools
    ... gcc: error trying to exec 'gnat1': execvp: No such file or directory ...
    (comp.lang.ada)