How would I run this as an apple executable file?

倖福魔咒の 提交于 2019-12-12 01:44:52

问题


so I have this simple executable .command file:

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

Whenever I run this, it displays this in the terminal:

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]

Why does it do this?


回答1:


You have inadvertently saved the file as RTF (Rich Text Format) using TextEdit, whereas the bash shell just wants plain text rather than documents containing italicised, bold or large font text.

Load the file again in TextEdit and press

++T

this corresponds to clicking menu items: Format->Make Plain Text. Now re-save over the existing file and all will work.

By the way, you can remove all the semi-colons and the exit as they are superfluous.



来源:https://stackoverflow.com/questions/41910170/how-would-i-run-this-as-an-apple-executable-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!