0

I have a MAC OSX objective C application say first.app ,in which i use NSAppleScript with admin privileges to run a shell script.This script is indented to launch another Objective C application say second.app.

When you use open command Ex: "open second.app" in shell script it works fine .

But if you launch the second.app by calling its binary Ex: "/second.app/Contents/MacOS/second " in shell script ,then the control don't come back to first.app until second.app closes . when we close the second.app then first.app resumes .

What is the difference in launching the application from open command and calling the applications binary directly as mentioned ?

user12345
  • 425
  • 1
  • 3
  • 14

1 Answers1

0

Calling

open Second.app

is the same as double-clicking the app's icon in the Finder. The application is started via LaunchServices, and the open command returns immediately.

Calling

/path/to/Second.app/Contents/MacOS/Second

starts the application directly (without LaunchServices), and returns only when the application has terminated.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
  • Thanks .It is really helpful .I have a doubt ,While running the binary directly we can make to run in backgroung Command "/path/to/Second.app/Contents/MacOS/Second 2>&1 &" .In this case script terminates .But still first.app didnt resume .Do you know the reason ? Does the NSAppleScript waits even for the application running in background ? – user12345 Jan 18 '13 at 07:46
  • @user1336309: Sorry, I don't know. You can try `nohup /path/to/Second.app/Contents/MacOS/Second >/dev/null 2>&1`, perhaps that helps. – Martin R Jan 18 '13 at 07:55
  • nohup is redirecting the standard output to that file . It didn't help .Thank you again . – user12345 Jan 18 '13 at 08:53
  • @user1336309: More accurately, `>/dev/null` redirects standard output to that file, and `2>&1` redirects stderr to stdout (so they both go to the same place). `nohup`'s effect is unrelated to redirection. – Peter Hosey Jan 18 '13 at 17:40