Launch an app on OS X with command line

前端 未结 12 1040
北恋
北恋 2020-12-04 06:03

I want to launch an app on OSX from a script. I need pass it command line arguments. Unfortunately, open doesn\'t accept command line args.

The only opt

12条回答
  •  暖寄归人
    2020-12-04 06:44

    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.

提交回复
热议问题