Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have an app name foo.app I want to open from command line (using open).

My folder structure is like this:

~
+---bar
     +--- foo.app
+---baz
     +--- foo.app

I want to open the app located in the bar folder, however if I do open -a foo.app, the app located in the baz folder will open, even if my current working directory is in the bar folder.

open -a ./foo.app or open -a ~/bar/foo.app doesn't work either.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

In this case, open -a is NOT what you want; the -a option is for launching known applications (indexed in the Launch Services database that lets you open a document and get the right application) by name, not by pathname, or for opening files with a given application.

What you are looking for is just plain opening foo.app, just like you double-clicked it in the Finder. To do that,

open foo.app

This will open exactly that application, without involving the Launch Services database at all.

share|improve this answer

open bar/foo.app/Contents/MacOS/foo

If you're using the -a parameter to open, then you need to omit the .app extension.

share|improve this answer
    
It doesn't matter if I omit the .app extension and what if the executable is not named foo? How would I get the executable name? Example :bar/foo.app/Contents/MacOS/foobar –  Tyilo Feb 5 '12 at 1:02
    
Typically the .app bundle and the actual executable file (in the Contents/MacOS/ directory) have the same name. So if the top-level directory is named foo.app, I would expect the executable file to be foo.app/Contents/MacOS/foo . –  bneely Feb 5 '12 at 1:06
    
But in this case it doesn't... –  Tyilo Feb 5 '12 at 1:24
    
Then you will need to go into the .app directory and determine the name of the executable file in order to type the correct open command. How did you obtain these apps? –  bneely Feb 5 '12 at 2:07
    
It's a jar bundled inside an app so the executable name is actually JavaApplicationStub. I also found out that the executable name is stored in the Info.plist as CFBundleExecutable. –  Tyilo Feb 5 '12 at 2:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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