From: Daniel A. S. <st...@ma...> - 2007-03-07 16:06:10
|
Kevin, On 07/03/2007, at 14:24, Kevin Walzer wrote: > Does anyone know if there is a way to get a Tcl/Tk application on the > Mac to write output to Console.app? That is a standard tool to get > error > messages from GUI applications. However, when I use "puts" > statements in > my programs to check error messages, they don't show up in Console, > just > in Terminal. when an app is opened from the Finder (or more generally via LaunchServices), stdout and stderr are sent to the OS console (and stdin is /dev/null), but because TkAqua uses the Tk console window in that case and redirects the stdout/stderr channels to it, you cannot [puts] to them to output to the OS console (but note that e.g. fprintf (stderr) from the C level does go to the OS console). However, you can [open] /dev/stdout or /dev/stderr from tcl to get access to the C level stdout and stderr (i.e. fd's 1 and 2), and [puts] to these will go to the console if Wish was started from Finder; or if you want to always output to the console, regardless of where the C stdout and stderr may have been redirected, you can open / dev/console from tcl: % set c [open /dev/console WRONLY] % fconfigure $c -buffering none % puts $c test Cheers, Daniel -- ** Daniel A. Steffen Dept. of Mathematics ** ** Macquarie University NSW 2109 Australia ** |