“点击执行”在 Mac OS X 中

发布于 2024-08-02 05:48:11 字数 310 浏览 6 评论 0原文

我有一个简短的脚本来启动我的应用程序(它使用一些参数调用 java)。该应用程序需要适用于 Mac OS X 的防奶奶启动器。该应用程序未安装,甚至未复制到主机磁盘,而是通过 USB 记忆棒提供。

当用户插入棒并打开它时,她应该能够单击一个适当命名的文件(例如 start_osx.sh 即可),这将执行其中的脚本。

我现在在这方面很失败。当我单击该文件时,它会在文本编辑器中打开。即使在文件上设置了 chmod +x 。

如果对我有帮助的话,可以选择将脚本编译为“本机”可执行文件。

如果我可以自定义文件浏览器中显示的文件图标,那就加分了。

I have a short script to start my application (it invokes java with some parameters). The application needs a grannny-proof launcher for Mac OS X. The application is not installed, it is not even copied to the host disk, it is instead delivered on USB sticks.

When the user inserts the stick and opens it up, she should be able to click an appropriately named file (start_osx.sh for instance would do) and this would execute the script inside.

I'm failing at this right now. When I click said file, it opens up in the text editor. Even if chmod +x is set on the file.

Compiling the script to a "native" executable is an option if that will help me.

Bonus points for if I can customize the file's icon as displayed in the file browser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

紧拥背影 2024-08-09 05:48:11

Mac OS X 启动应用程序包(具有给定结构的文件夹)。
您可以使用 platypus 将 shell 脚本包装在应用程序包中。

应用程序图标是应用程序包内容的一部分。

Mac OS X launches application bundles (folder with a given structure).
You can wrap your shell script inside an application bundle by using platypus.

The application icon is part of the application bundle content.

紅太極 2024-08-09 05:48:11

.command 添加到文件名(即 start_osx.sh.command)

这将执行,但工作目录作为用户的主文件夹。

添加

cd "`dirname "$0"`"

到脚本中,工作目录将是启动脚本的目录。

Add .command to the filename (i.e. start_osx.sh.command)

This will execute, but with the working directory as the user's home folder.

Add

cd "`dirname "$0"`"

To the script and the working directory will be the directory the script was launched from.

梦幻之岛 2024-08-09 05:48:11

或者,您可以创建运行该应用程序的 AppleScript。

Alternatively, you can create an AppleScript that runs the application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文