使用命令行在OS X上启动应用 [英] Launch an app on OS X with command line

查看:81
本文介绍了使用命令行在OS X上启动应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过脚本在OSX上启动应用程序.我需要通过命令行参数.不幸的是,open不接受命令行参数.

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.

我唯一想到的选择是使用nohup myApp > /dev/null &来启动我的应用程序,以便它可以独立于启动它的脚本而存在.

The only option I can think of is to use nohup myApp > /dev/null & to launch my app so it can exist independently of the script that launches it.

还有更好的建议吗?

推荐答案

在OS X 10.6中,

In OS X 10.6, the open command was enhanced to allow passing of arguments to the application:

open ./AppName.app --args -AppCommandLineArg

但是对于Mac OS X的较旧版本,并且由于应用程序捆绑包并非旨在传递命令行参数,因此常规机制是使用此处(可可应用程序)或此处(适用于Carbon应用).您还可以通过使用环境变量传递参数来做一些麻烦的事情.

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.

这篇关于使用命令行在OS X上启动应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆