我如何 运行 将其作为苹果可执行文件?

How would I run this as an apple executable file?

所以我有了这个简单的可执行 .command 文件:

#!/bin/bash
cd Desktop;
python hoi.py;
exit;

每当我 运行 这个,它会在终端显示这个:

Tom-Diterwich:~ student$ /Users/student/Desktop/run.command ; exit;

/Users/student/Desktop/run.command: line 1:{rtf1ansiansicpg1252cocoartf1348cocoasubrtf170: command not found

/Users/student/Desktop/run.command: line 2: syntax error near unexpected token `}'

/Users/student/Desktop/run.command: line 2: `{\fonttbl\f0\fmodern\fcharset0 Courier;}'

logout

[Process completed]

为什么会这样?

您使用 TextEdit 无意中将文件保存为 RTF(富文本格式),而 bash shell 只需要纯文本而不是文档包含斜体、粗体或大字体文本。

TextEdit 中再次加载文件并按

++T

这对应于单击菜单项:格式->制作纯文本。现在 re-save 覆盖现有文件,一切正常。

顺便说一句,您可以删除所有 semi-colons 和 exit,因为它们是多余的。