Launch an app on OS X with command line
As was mentioned in the question here, the open
command in 10.6 now has an args
flag, so you can call:
open -n ./AppName.app --args -AppCommandLineArg
In OS X 10.6, the open
command was enhanced to allow passing of arguments to the application:
open ./AppName.app --args -AppCommandLineArg
But for older versions of Mac OS X, and because app bundles aren't designed to be passed command line arguments, the conventional mechanism is to use Apple Events for files like here for Cocoa apps or here for Carbon apps. You could also probably do something kludgey by passing parameters in using environment variables.
An application bundle (a .app
file) is actually a bunch of directories. Instead of using open
and the .app
name, you can actually move in to it and start the actual binary. For instance:
$ cd /Applications/LittleSnapper.app/
$ ls
Contents
$ cd Contents/MacOS/
$ ./LittleSnapper
That is the actual binary that might accept arguments (or not, in LittleSnapper
's case).