Re: print application stdout to terminal?
Re: print application stdout to terminal?
- Subject: Re: print application stdout to terminal?
- From: Ken Thomases <email@hidden>
- Date: Sat, 12 Jul 2008 23:42:39 -0500
On Jul 12, 2008, at 10:25 PM, Liam Staskawicz wrote:
Hi - I realize this is not entirely Xcode specific, but I wasn't
sure where else to post and was thinking there was a reasonable
chance somebody here might have done this before.
Normally, when running my app from within Xcode my stdout makes it
into the Debug window and all is well. However, I have a test suite
that runs as a separate .app that gets launched from a script as
part of a testing process. The only place I can hunt down the
stdout from this app is in Console.app. That's not disastrous,
really, but as I'm opening up the app from Terminal.app with the
'open' command, it would be great to see stdout right there.
A 'man open' does not immediately reveal any flags that might
redirect the output. Any thoughts? Thanks!
/usr/bin/open uses Launch Services to open applications, files, and/or
URLs. Therefore, it's roughly equivalent to double-clicking the item
in the Finder. Launch Services doesn't provide any way to redirect
stdout or stderr, so neither does "open".
However, if you're using a script to launch an application in certain
very constrained circumstances (such as a testing process), you may
directly execute the executable within an application bundle to launch
it, and exercise full control of stdout and stderr. For example,
instead of:
open /path/to/MyApplication.app
you could use:
/path/to/MyApplication.app/Contents/MacOS/MyApplication >/tmp/myoutput
2>/tmp/myerrors &
If you want the output to simply show up in the Terminal window, just
don't redirect it to a file.
Note that your application won't receive the usual start-up Apple
Event (oapp). If your application is already running, a _second
instance_ will be started, where Launch Services would not do that.
Launch Services would activate the already-running instance and
deliver an 'rapp' event. Similarly, you can't deliver an open-
document ('odoc') event at startup this way, either, although you can
request the application to open a document after it has started up
using the "open" command (open -a MyApplication /path/to/document).
Cheers,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden