4

I'm working with a program that I can't reasonably run from console; it is started by another program with complex calculated and network-gotten arguments, and that program is complicated as well.

To view output on Windows I can AllocConsole, but it seems there is no such equivalent for Mac. According to Ivan Vučica, "A console is "allocated" by default. You cannot order the OS to open a console though." (link).

His answer gives some good information, but little useful in a reverse-engineering context as I don't have the project.

So, if I really, really, really want to get a console instead of outputting to a file or creating some GUI, what might I do? If project options allows for enabling / disabling console, presumably there is some flag in the .app. Is it editable? Are there other options?

1 Answer 1

2

It really depends what the application you are trying to run is logging to.

If the application uses NSLog() and other associated Cocoa APIs, you're in luck. The output should appear in the Apple system log and can be viewed and caputired using Console.app.

If the application is logging to stdout, things get a little more challenging. From how to get stdout into Console.app on Stack Overflow:

Prior to Mountain Lion, all processes managed by launchd, including regular applications, had their stdout and stderr file descriptors forwarded to the system log. In Mountain Lion and above, stdout and stderr go nowhere for launchd managed applications. Only messages explicitly sent to the system log will end up there.

I'm not sure it would be possible to see these log messages, unless you were to redirect stdout or somehow hook into whatever function that application was using to log and ASL (now deprecated) or os_log.

If you're lucky, you can run the original OS X bundle application from the command line, and look for any useful logging from there.

5
  • As a first step, do you know how to make the console appear in the first place? Running it from a console instance isn't an option.
    – Lupe
    Nov 19, 2016 at 22:08
  • @Lupe Console.app? It's under Application -> Utilities -> Console. And to run an OS X application from the command line you would just reference the path of the binary in the bundle: /Applications/Xcode.app/Contents/MacOS/Xcode.
    – JAL
    Nov 19, 2016 at 22:13
  • I may be misunderstanding, but while I know how to open Console.app, I can't run my target application from it because it has extremely complicated and network-dependent launch args. It's normally launched by a launcher app.
    – Lupe
    Nov 19, 2016 at 22:16
  • You don't run the application from Console.app. Console.app is just a frontend to Apple System Logger. Launch your app normally and then check Console.app for any logging info from the application.
    – JAL
    Nov 19, 2016 at 22:17
  • Ahh, sorry for my ignorance. I had no idea it existed. This is exactly what I wanted, thank you!
    – Lupe
    Nov 19, 2016 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.