4

Is there a way for a Cocoa application to tell if it's being run interactively or from something like cron? Basically I want to have the GUI appear if it's a person running the command, but if it's being called from something like cron, then I don't want the GUI to show.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Gargoyle
  • 9,590
  • 16
  • 80
  • 145

2 Answers2

0

Sounds like you are looking for the isatty function (which is probably what perl's -t test uses).

if (isatty(0)) {
    // standard input is a “tty” hence I should run interactively
}
rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • When the application is started from the Finder, [that expression returns false](http://i.stack.imgur.com/HlB43.png). I asked the questioner for clarification in the comments on the question; it appears that the presence of a TTY specifically is not actually what they are interested in. – Peter Hosey Jul 15 '13 at 05:05
0

You can use launchctl list command.

With no arguments, list all of the jobs loaded into launchd

Parag Bafna
  • 22,812
  • 8
  • 71
  • 144