bash Shell 脚本返回:run.sh: line 10: SET: command not found
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33927745/
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
Shell script returns: run.sh: line 10: SET: command not found
提问by Bart Dangus
I'm trying to run a shell script so I can boot up my local version of a Meteor app that I'm working on. I've never used shell scripts before this, but got the thing running when I was working with the head developer. So this is my run.shfile:
我正在尝试运行一个 shell 脚本,以便我可以启动我正在开发的 Meteor 应用程序的本地版本。在此之前我从未使用过 shell 脚本,但是当我与首席开发人员一起工作时,它运行起来了。所以这是我的run.sh文件:
@echo off
c:
cd /Users/ten3/Desktop/git/ten/website/prospect-recovery/prospect-recovery
SET ROOT_URL=http://localhost
SET SPECIAL_RUN=no
SET NO_BATCH=no
SET NO_MAIL=no
SET MAIL_GUN_TEST=yes
SET MAIL_THROTTLE_INTERVAL=0
SET NODE_OPTIONS=%1
SET SHORT_URL=http://sota.ddns.net
SET NODE_PATH=%AppData%\npm
meteor --port 80
echo “works”
I'm pretty clueless as to what these actually do, aside from keep my local copy of the app interacting with other APIs. Every time I try to run the script I get:
除了保持应用程序的本地副本与其他 API 交互之外,我对这些实际上做了什么一无所知。每次我尝试运行脚本时,我都会得到:
run.sh: line 4: @echo: command not found
run.sh: line 6: c:: command not found
run.sh: line 10: SET: command not found
run.sh: line 12: SET: command not found
run.sh: line 14: SET: command not found
run.sh: line 16: SET: command not found
run.sh: line 18: SET: command not found
run.sh: line 20: SET: command not found
run.sh: line 22: SET: command not found
run.sh: line 24: SET: command not found
run.sh: line 26: SET: command not found
Error: listen EACCES
“works”
I've tried changing the file permissions, using sudo, tried including the file location in the paths it looks for it, tried including bash within my file, tried running the file inside the directory run.sh is, pretty much everything I can google. I can't figure out what I'm missing, and would like to die.
我尝试使用 sudo 更改文件权限,尝试在它查找的路径中包含文件位置,尝试在我的文件中包含 bash,尝试在 run.sh 目录中运行文件,几乎所有我可以谷歌搜索. 我无法弄清楚我错过了什么,并且想死。
回答by user3159253
You should rewrite it for bash or another shell for a unix-like operating system (there're many alternatives, with bash
is the most common).
您应该为 bash 或其他类似 Unix 的操作系统的 shell 重写它(有很多替代方案,其中bash
最常见)。
#!/bin/sh
cd /some/required/path
ROOT_URL='http://localhost'
SPECIAL_RUN='no'
...
NODE_OPTIONS="" # notice double quotes, single quotes don't perform $variable expansion
SHORT_URL="http://sota.ddns.net"
NODE_PATH=/actual/path/to/npm
export ROOT_URL SPECIAL_RUN ... NODE_OPTIONS SHORT_URL NODE_PATH
./meteor --port 80 # since the port is below 1024, it's privileged, and the script should be run from root. Use ports > 1024 to run as a user
To run a program or a script from a given directory, you may specify a /full/path/to/the/program
or simply include /path/to/the
to PATH
. By default current directory isn't in PATH for security reasons (unlike in Windows).
要从给定目录运行程序或脚本,您可以指定一个/full/path/to/the/program
或简单地包含/path/to/the
到PATH
。默认情况下,出于安全原因,当前目录不在 PATH 中(与 Windows 中不同)。