exec and non-zero exit-codes

From: Andreas Leitgeb (avl_at_gamma.logic.tuwien.ac.at)
Date: 06/25/04


Date: 25 Jun 2004 08:46:07 GMT

Every once in a while, I need to exec some program from my
Tcl-scripts, and deal with the fact that these programs may
return an exit-code !=0, or even ==0 but issue an harmless
warning to stderr, which will all cause exec to throw an
exception.
If, otoh, I just catch the exec, then I won't even notice
if the program itself was executed, or whether I just mistyped
some variable name in the arguments.

It is surely possible to make some procedure to wrap exec
which will catch, check ::errorCode and re-throw the exception
if anything else than non-zero exit-status or stderr-output
triggered the error and return the real exit-status (and
eventually store the output to a specified variable).

The question is: has such a procedure been written already
and is available, or would I have to do it myself?

PS: I've read about [try ...], and it would surely help to
  implement the procedure I'm after, but its not yet the
  whole answer.



Relevant Pages

  • Re: Problem in calling c programs and compiling them in tcl/tk
    ... using exec gcc filename.c and later exec ./a.out filename.c. ... use their exit status for abnormal exits, and that has spoilt the Tcl ... Hmmm, not exactly, since this would *hide* what happens on stderr, ...
    (comp.lang.tcl)
  • Re: Problem in calling c programs and compiling them in tcl/tk
    ... the fact that barfs by default if the child process ... writes to its stderr. ... tell exec not to complain about it. ... have given the original poster more complete help earlier in the day. ...
    (comp.lang.tcl)
  • Re: Re: [Tcl] exec like in a shell
    ... > that exec returns and exec won't error unless ... the process I spawn can print something on stderr that I DO care. ... name for a temporary file as well as dropping output to a file (to be read ... Opinions presented by me on usenet groups are my personal opinions ONLY and are not connected to the employer. ...
    (comp.lang.tcl)
  • Re: Problem in calling c programs and compiling them in tcl/tk
    ... the fact that barfs by default if the child process ... Hmmm, not exactly, since this would *hide* what happens on stderr, ... tell exec not to complain about it. ... have given the original poster more complete help earlier in the day. ...
    (comp.lang.tcl)
  • Re: Problem in calling c programs and compiling them in tcl/tk
    ... using exec gcc filename.c and later exec ./a.out filename.c. ... use their exit status for abnormal exits, and that has spoilt the Tcl ... That won't help for the stderr writes of gcc... ...
    (comp.lang.tcl)