Prev: search for a string in a file using expect..
Next: Detecting if a file is still opened by another program
From: YoCmos on 16 Jul 2010 08:40 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. 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.
From: Alexandre Ferrieux on 16 Jul 2010 08:48 On Jul 16, 2:40 pm, 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
From: Robert Heller on 16 Jul 2010 09:44 At Fri, 16 Jul 2010 05:48:46 -0700 (PDT) Alexandre Ferrieux <alexandre.ferrieux(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 > > -- Robert Heller -- Get the Deepwoods Software FireFox Toolbar! Deepwoods Software -- Linux Installation and Administration http://www.deepsoft.com/ -- Web Hosting, with CGI and Database heller(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk
From: YoCmos on 16 Jul 2010 10:04 I probably didn't explain myself correctly. Here is it: The stderr of the program I execute is displayed like it was an ordinary error(a TK error message box). The only thing I want it to do is to put the sterr in a variable and not to show this error message box. I'l try the "catch" command. thanks.
From: YoCmos on 16 Jul 2010 10:12 Worked!! I tried to put catch but it didn't help. Then I added an "exit 0" line in the end of the .bat file and that's it - no more error boxes! Thanks everybody, I wonder if there is a more good looking solution for this...
|
Next
|
Last
Pages: 1 2 Prev: search for a string in a file using expect.. Next: Detecting if a file is still opened by another program |