我有一个shell脚本,在OS X上有用户执行权限,但当我双击它时,它在文本编辑器中打开。如何通过双击它来运行它?
当前回答
Chmod 774文件名
注意:带有bash脚本的文件名为'filename'的文件没有扩展名
其他回答
First in terminal make the script executable by typing the following command: chmod a+x yourscriptname Then, in Finder, right-click your file and select "Open with" and then "Other...". Here you select the application you want the file to execute into, in this case it would be Terminal. To be able to select terminal you need to switch from "Recommended Applications" to "All Applications". (The Terminal.app application can be found in the Utilities folder) NOTE that unless you don't want to associate all files with this extension to be run in terminal you should not have "Always Open With" checked. After clicking OK you should be able to execute you script by simply double-clicking it.
简单的方法是将扩展名更改为.command或不扩展名。
但这会打开终点站,你必须关闭终点站。如果你不想看到任何输出,你可以使用Automator创建一个Mac应用程序,你可以双击,添加到dock等。
打开Automator应用程序 选择“应用程序”类型 在Actions搜索框中输入“run” 双击“运行Shell脚本” 单击右上角的Run按钮来测试它。 文件>保存以创建应用程序。
你也可以使用RCDefaultApp通过文件扩展名设置默认值:
http://www.rubicode.com/Software/RCDefaultApp/
潜在地,你可以设置.sh打开在iTerm/终端等,这需要用户执行权限,例如
chmod u+x filename.sh
你试过使用.command文件扩展名吗?
或者,你也可以使用Platypus从你的脚本创建一个常规的Mac OS X应用程序