Launch an app on OS X with command line

前端 未结 12 1053
北恋
北恋 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:34

    Beginning with OS X Yosemite, we can now use AppleScript and Automator to automate complex tasks. JavaScript for automation can now be used as the scripting language.

    This page gives a good example example script that can be written at the command line using bash and osascript interactive mode. It opens a Safari tab and navigates to example.com.

    http://developer.telerik.com/featured/javascript-os-x-automation-example/
    osascript -l JavaScript -i
    Safari = Application("Safari");
    window = Safari.windows[0];
    window.name();
    tab = Safari.Tab({url:"http://www.example.com"});
    window.tabs.push(tab); 
    window.currentTab = tab;
    

提交回复
热议问题