Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stop tcl from taking over with errors from other apps

Status
Not open for further replies.

Breadcrust

Programmer
Oct 27, 2003
42
0
0
AU
whenever i run a program (open "|command" r) and it outputs out an error, tcl takes over and wish spits out an error dialog without the chance for my program to take control!

how can i stop tcl doing this?, its really pissing me off >:-
[tt]
Breadcrust (aka J@red)

Web - E-mail - net-head@softhome.net
Linux Reg. Number - 307180 ([/tt]
 
Try catch or exec..but really, what do you expect
to happen when an error occurs in an application
that you are running through the tcl interpreter?

I don't think we are getting the full story here
because otherwise your question is just kind of
a gripe without any real purpose.
 
i try to run make using open and when ever make outputs an error (or even a warning) tcl takes over. i would just like my program to detect the error and handle it itself.

ive tryed using catch, but in my situation, it is a little annoying. i guess i could change the program to work with catch but i would just like to disable tcl producing an error

[tt]
Breadcrust (aka J@red)

Web - E-mail - net-head@softhome.net
Linux Reg. Number - 307180 ([/tt]
 
As you've discovered, when working with pipelines in Tcl, you can encounter an error condition if:[ul][li]one of the programs in the pipeline exits with a non-zero exit code, or[/li][li]one of the programs writes to its standard error ([tt]stderr[/tt]) channel and you don't explicitly redirect [tt]stderr[/tt] when you create the pipeline.[/li][/ul]This error is usually thrown when you attempt to close the channel. So it's a good policy to always catch your close when working with pipes in Tcl.

Without seeing the code, it's a bit difficult to advise the best approach to take. But it's basically going to be either catch the close (which I recommend regardless), and/or tell open how you want [tt]stderr[/tt] handled in your pipeline. You could redirect [tt]stderr[/tt] to a file, redirect it to another open file descriptor, discard it by redirecting it to /dev/null, or merge it with the [tt]stdout[/tt] channel, in which case it will show up interleaved with the rest of your program's output.

Several of these techniques are explained on the Tcl'ers Wiki ( You might try starting with the pages "open," and "stderr,"
Another option you might consider, if it's feasible in your situation, is to use the bgerror command from the BLT extension. It has some really nice features for dealing with external programs, including managing the [tt]stderr[/tt] channel. You can find out more information at "bgerror," and "BLT,"
- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Oops. I typed the wrong command name. It isn't bgerror, but bgexec. At least I gave the correct Wiki page link.

- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top