0

I need to check the path to a program -- I want to point to the binary, not to the ".app" which is a directory. How do I do this?

  • 1
    Almost every .app foder on OSX has it's binary inside Contents/MacOS folder. For example: /Applications/Mail.app/Contents/MacOS/Mail. To see the .app in Finder simply ⌘+Click it's icon in the Dock. – Mateusz Szlosek Jul 24 '14 at 15:22
  • 2
    Most of the times the binary is named after the app but to double check, just right click on the app, choose Show Package Contents and navigate to the path mentioned by Mateusz. – user36018 Jul 24 '14 at 15:37
  • 1
    What are you exactly trying to do? – bmike Jul 24 '14 at 16:52
  • @MateuszSzlosek - put it as Answer :) completely correct – bMalum Jul 25 '14 at 6:12
  • 1
    @megadroid same for you ;) – bMalum Jul 25 '14 at 6:13
1

Navigate to your Applications folder, right click on any app, choose Show Package Contents and navigate to Contents/MacOS/. Most of the times, the binary is named after the app so, if using the path on a script, you'll be mostly safe by using /Applications/(appname).app/Contents/MacOS/(appname), where (appname) is, well, the name of the app. If the app name has a whitespace in it, eg. Sublime Text, don't forget to put the path between double quotes (or escape it), in your script.

  • Applications don't have to be in /Applications, they can be anywhere – user151019 Jul 25 '14 at 21:21
  • True but /Applications always has applications in it, even if just OS X stock applications. I just provided Applications as a base folder example so I could construct the full path to the binary. – user36018 Jul 26 '14 at 1:30
1

As @megadroid posted, Applications have executable in Contents/MacOS directory. However executable name not necessarily is the same as app name. To get exact executable name, You can read it from Info.plist file (under CFBundleExecutable key) or do it from Terminal.app with for example:

APP_PATH="/Applications/Mail.app"
echo "$APP_PATH"/Contents/MacOS/$(defaults read "$APP_PATH/Contents/Info.plist" CFBundleExecutable)

Just change APP_PATH variable. Result: /Applications/Mail.app/Contents/MacOS/Mail

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .