Re: [MACTCL] Launcher "gotcha"... arghhh!

John,
On Wednesday, Jul 23, 2003, at 12:08 Australia/Sydney, John Seal wrote:
> I'm not sure what's the right way to fix this, because Aqua doesn't
> really have stderr and console output unless you specifically arrange
> for it. I haven't looked at Launcher to see how it causes Wish to
> source the file, but perhaps it could [catch] errors and report them?
I set things up in Launcher so that stdout/stderr go to the system
console when not redirected, so any errors will shown up in
/var/tmp/console.log, c.f the readme:
stdin/stdout/stderr are passed from Launcher to the child apps, i.e.
if Launcher is started by
the Finder, this means stdout/stderr will go to the console and stdin
will be /dev/null.
if you launch /Applications/Utilities/Console you can easily keep an
eye on this file (as well as on other logfiles BTW, e.g. I always have
this open to keep track of my procmail log file...)
this certainly works with tclsh, and indeed a .tcl file with an invalid
command that is execd by Launcher gives an error message in the console.
With wish, the problem is that when launched from the finder (directly
or via Launcher), stdin is /dev/null which puts wish in tk console
mode, so all error messages go there, but as the tk console is hidden
you can't see them...
this is really a generic wish issue and has nothing to do with launcher
per se.
one way to workaround it is to start your script from the Terminal via
"wish blah.tk"
or you could rewrite your script to run your main proc from the event
loop.
AquaWish startup should maybe be enhanced to only redirect
stdin/stdout/stderr to the tk console after the startup script has run,
so that output generated before the event loop starts running would go
somewhere visible; not sure if that would not have other repercussions
though?
Cheers,
Daniel
--
** Daniel A. Steffen ** "And now for something completely
** Dept. of Mathematics ** different" Monty Python
** Macquarie University ** <mailto:steffen@...>
** NSW 2109 Australia ** <http://www.maths.mq.edu.au/~steffen/&gt;

Thread view

Well, I just spent over an hour tracking down this little bugger!
I wanted to polish a Tcl program I'd written back in 2001, so I copied
it from the old OS 9 partition to the new OS X 10.2.6 partition. I
changed the extension from .tcl to .tk because I wanted it to run in
Wish. It already had the Launcher icon after I copied it, but when I
double-clicked it, nothing happened!
I read the Readme (what a concept!) and figured the problem was that my
scripts somehow ended up +x and Launcher was trying to exec them. I
cleared the execute bits, but it still wouldn't launch. Back to the
Readme, and the hunt was on: I could launch Wish and source the file,
and that seemed to work OK (remember that phrase "seemed to work"!). I
reinstalled TclTkAquaBI. I tried reassigning .tk to open with
Launcher. I tried "open all". Nothing worked. I ran "top", and it
showed Launcher and then Wish Shell launching, but they didn't stick
around. Ah ha! On a whim I created a test script
console show
puts "I made it!"
return
and, lo and behold, that worked! So I resorted to stepping those lines
through my script until I found the problem. Let me give you a hint:
the script was so old that it used [beep] instead of [bell]. One of
the last things the program did before falling into the event loop was
ring the bell. When I sourced the file, the GUI came up and I never
noticed that the console showed an "unknown command" error. I thought
everything was OK. But when Launcher launches the file, the error
causes Wish to bail out so I never saw the GUI.
I'm not sure what's the right way to fix this, because Aqua doesn't
really have stderr and console output unless you specifically arrange
for it. I haven't looked at Launcher to see how it causes Wish to
source the file, but perhaps it could [catch] errors and report them?
Like I said, arghhh!

John,
On Wednesday, Jul 23, 2003, at 12:08 Australia/Sydney, John Seal wrote:
> I'm not sure what's the right way to fix this, because Aqua doesn't
> really have stderr and console output unless you specifically arrange
> for it. I haven't looked at Launcher to see how it causes Wish to
> source the file, but perhaps it could [catch] errors and report them?
I set things up in Launcher so that stdout/stderr go to the system
console when not redirected, so any errors will shown up in
/var/tmp/console.log, c.f the readme:
stdin/stdout/stderr are passed from Launcher to the child apps, i.e.
if Launcher is started by
the Finder, this means stdout/stderr will go to the console and stdin
will be /dev/null.
if you launch /Applications/Utilities/Console you can easily keep an
eye on this file (as well as on other logfiles BTW, e.g. I always have
this open to keep track of my procmail log file...)
this certainly works with tclsh, and indeed a .tcl file with an invalid
command that is execd by Launcher gives an error message in the console.
With wish, the problem is that when launched from the finder (directly
or via Launcher), stdin is /dev/null which puts wish in tk console
mode, so all error messages go there, but as the tk console is hidden
you can't see them...
this is really a generic wish issue and has nothing to do with launcher
per se.
one way to workaround it is to start your script from the Terminal via
"wish blah.tk"
or you could rewrite your script to run your main proc from the event
loop.
AquaWish startup should maybe be enhanced to only redirect
stdin/stdout/stderr to the tk console after the startup script has run,
so that output generated before the event loop starts running would go
somewhere visible; not sure if that would not have other repercussions
though?
Cheers,
Daniel
--
** Daniel A. Steffen ** "And now for something completely
** Dept. of Mathematics ** different" Monty Python
** Macquarie University ** <mailto:steffen@...>
** NSW 2109 Australia ** <http://www.maths.mq.edu.au/~steffen/&gt;

On Wednesday, July 23, 2003, at 02:55 AM, Daniel A. Steffen wrote:
> I set things up in Launcher so that stdout/stderr go to the system
> console when not redirected, so any errors will shown up in
> /var/tmp/console.log, c.f the readme:
Hmm... I had Console open; maybe I wasn't looking at the right file.
> AquaWish startup should maybe be enhanced to only redirect
> stdin/stdout/stderr to the tk console after the startup script has
> run, so that output generated before the event loop starts running
> would go somewhere visible; not sure if that would not have other
> repercussions though?
That sounds like a reasonable approach.
"He always ate in the Steak Bar. He loved to drive in his Jaguar."
- Pink Floyd, Welcome to the Machine