Version 9 of stdout

Updated 2003-12-28 15:26:52

a part of stdio, this filehandle is opened by default for each application making use of the stdio package of code.

This output file may correspond to a disk file, pipe, terminal device, or other construct.

To refer to this output filehandle in Tcl, use the string stdout when using puts .


Tcl 8.3 had a problem on stdout, when it was redirected to a file. The problem was that every buffer write caused a flush of the disk cache. The workaround in 8.3 was to do (once, at beginning of script):

    fconfigure stdout -buffering full -buffersize 262144

so that there were few disk writes performed. (Thanks KBK and the Tcl chatroom for the quick answer! RS)


LV anyone want to address the situation with stdio and Windows? Are the file handles available by default? What do you have to do to see the output going to stdout?

BR - 2003-12-14 - Are you asking about wish.exe? tclsh.exe does have a normal stdout like any Windows console application.

wish.exe on Windows doesn't have Windows-level stdout, stderr or stdin. That is a consequence of being a Windows GUI app.

With 8.4, you should be able to use tclsh.exe instead, if you want a GUI and console I/O at the same time. You need to add a package require Tk to the top of your script to load Tk as an extension, unless the script already has that. That statement doesn't do any harm if the script is actually executed in wish.exe, so you don't need a separate script for this.

You can also call console show from a script running in wish.exe (check first if the console command exits, if you want to be portable). That gives you the normal interaction window as used in interactive Wish sessions in addition to your application. It will also show any output that you write to the stdout and stderr Tcl channels.


Category Glossary | Category Concept