macos 如何在 Mac 上运行脚本文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10154866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run a script file on Mac?
提问by Ahmed Hussein
I have searched on how to run a script file on Mac but nothing works for me.
我已经搜索了如何在 Mac 上运行脚本文件,但没有任何效果对我有用。
Every time I tried sudo script-name
the terminal responds with
每次我尝试sudo script-name
终端时都会响应
-bash: /Users/macuser/Desktop/tesseract-3.01: is a directory
-bash: /Users/macuser/Desktop/tesseract-3.01: 是一个目录
The file I want to run is called start
and it's located in tesseract-3.01
directory on the desktop.
我要运行的文件被调用start
,它位于tesseract-3.01
桌面上的目录中。
回答by Sicong
simply do
简单地做
/Users/macuser/Desktop/tesseract-3.01/start
or if it's actually called start.sh
或者如果它实际上被称为 start.sh
/Users/macuser/Desktop/tesseract-3.01/start.sh
you might also want to do
你可能还想做
chmod +x /Users/macuser/Desktop/tesseract-3.01/start.sh
to change the script to be executable before you run the script
在运行脚本之前将脚本更改为可执行
回答by Marc
sudo /Users/macuser/Desktop/tesseract-3.01/start
You have to indicate the script name, but it looks like you were only specifying the directory.
您必须指明脚本名称,但看起来您只是指定了目录。
You could also cd
to the directory and then run it like so:
您也可以cd
进入该目录,然后像这样运行它:
cd /Users/macuser/Desktop/tesseract-3.01
sudo ./start
回答by Marlon
Try
尝试
sudo ./Users/macuser/Desktop/tesseract-3.01/start.sh
or
或者
cd /Users/macuser/Desktop/tesseract-3.01
then
然后
sudo ./start.sh
sudo ./start.sh