From: Alexandre Ferrieux on
On Jul 16, 3:44 pm, Robert Heller <hel...(a)deepsoft.com> wrote:
> At Fri, 16 Jul 2010 05:48:46 -0700 (PDT) Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> wrote:
>
>
>
>
>
>
>
> > On Jul 16, 2:40=A0pm, YoCmos <yrei...(a)gmail.com> wrote:
> > > I have a program that writes to stderr and I want to execute it with
> > > "exec".
> > > When I do this, TCL shows me an error message as though it was an
> > > ordinary TCL error.
>
> > Any reason not to paste the error message here ? You playing a
> > guessing game ?
>
> > > I simply want the output of this program to go to a variable. this is
> > > what I did:
> > > set compiler "bin/tecs-software-suite-2.5/JackCompiler.bat"
> > > set s [exec $compiler $current_file 2>@1]
> > > the 2>@1 doesn't help, it's still showing me a TCL error. I tried -
> > > ignorestderr but it also didn't work.
> > > I work with tcl 5.8.5 on Win7
> > > please help.
>
> > I don't know for Windows, but in unix the other reason for an error in
> > exec (beside the non-redirected stderr) , is a nonzero exit status.
>
> > The usual workaround, when you are using a frozen child with a non-
> > fixable error status, is to wrap it in a shell invocation finished by
> > "; exit 0":
>
> >    exec sh -c "some rogue-exit command; exit 0" 2>@1
>
> > Maybe a similar form exists for .BATs, but I don't know the syntax.
>
> > -Alex
>
> The other solution is to use catch (this will work on any O/S):
>
> catch {exec some rogue-exit comand} result

The problem is that in that case $result will contain the
concatenation of the output and the message "child process exited
abnormally", needing extra parsing to remove it.

-Alex
From: Robert Heller on
At Fri, 16 Jul 2010 07:15:25 -0700 (PDT) Alexandre Ferrieux <alexandre.ferrieux(a)gmail.com> wrote:

>
> On Jul 16, 3:44=A0pm, Robert Heller <hel...(a)deepsoft.com> wrote:
> > At Fri, 16 Jul 2010 05:48:46 -0700 (PDT) Alexandre Ferrieux <alexandre.fe=
> rri...(a)gmail.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Jul 16, 2:40=3DA0pm, YoCmos <yrei...(a)gmail.com> wrote:
> > > > I have a program that writes to stderr and I want to execute it with
> > > > "exec".
> > > > When I do this, TCL shows me an error message as though it was an
> > > > ordinary TCL error.
> >
> > > Any reason not to paste the error message here ? You playing a
> > > guessing game ?
> >
> > > > I simply want the output of this program to go to a variable. this is
> > > > what I did:
> > > > set compiler "bin/tecs-software-suite-2.5/JackCompiler.bat"
> > > > set s [exec $compiler $current_file 2>@1]
> > > > the 2>@1 doesn't help, it's still showing me a TCL error. I tried -
> > > > ignorestderr but it also didn't work.
> > > > I work with tcl 5.8.5 on Win7
> > > > please help.
> >
> > > I don't know for Windows, but in unix the other reason for an error in
> > > exec (beside the non-redirected stderr) , is a nonzero exit status.
> >
> > > The usual workaround, when you are using a frozen child with a non-
> > > fixable error status, is to wrap it in a shell invocation finished by
> > > "; exit 0":
> >
> > > =A0 =A0exec sh -c "some rogue-exit command; exit 0" 2>@1
> >
> > > Maybe a similar form exists for .BATs, but I don't know the syntax.
> >
> > > -Alex
> >
> > The other solution is to use catch (this will work on any O/S):
> >
> > catch {exec some rogue-exit comand} result
>
> The problem is that in that case $result will contain the
> concatenation of the output and the message "child process exited
> abnormally", needing extra parsing to remove it.

Yes, of course. But this is not partitularly hard. There are several
ways of dealing with that, including regexp and regsub. Once the output
is captured and unwanted error message suppresed, everything else is
easy and straightforward.

>
> -Alex
>

--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
heller(a)deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/