问题描述
|
我正在写一个shell脚本。我正在阅读的教程的第一行是这样的:
#!/usr/bin/env bash/
但这对我不起作用。 (error : no such directory
)
我如何找出正在使用的bash及其位置?
感谢任何建议和帮助。
非常感谢。现在可以使用了。
解是#!/usr/bin/env bash
另一个问题:为什么它只是看不懂“重启”这个词
我在start.sh中的代码:
#!/usr/bin/env bash/
RESTART=\"apachectl restart\"
$RESTART
我不工作
Usage: /usr/local/apache2/bin/httpd [-D name] [-d directory] [-f file]
[-C \"directive\"] [-c \"directive\"]
[-k start|restart|graceful|graceful-stop|sto p]
[-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
-D name : define a name for use in <IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C \"directive\" : process directive before reading config files
-c \"directive\" : process directive after reading config files
-e level : show startup errors of level (see LogLevel)
-E file : log startup errors to file
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-L : list available configuration directives
-t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)
-S : a synonym for -t -D DUMP_VHOSTS
-t -D DUMP_MODULES : show all loaded modules
-M : a synonym for -t -D DUMP_MODULES
-t : run Syntax check for config files
为什么会这样呢?看来它可以读取重新启动一词。
谢谢你们!我已经修复了。
解决方案:在Unix中编辑文件(vim / nano等,但在Windows中不行)
Thank again :)
解决方法
您可以尝试以下命令
which bash
在壳。然后放
#!<the output of which bash>
,另一种方式:echo $SHELL
。
,如果将ѭ9从ѭ10移开,它应该可以工作。
,要找出bash在哪里,请发出以下命令:
type bash
在命令提示符下。并确保始终在您的脚本中找到它,请使用:
#!bash
这样做的问题是可能会发现并使用其他一些bash,这可能是安全问题,但是我已经这样做了多年。
,删除行尾的多余字符。不需要斜杠,并且
dos2unix yourscript
将删除不需要的CR。
#!/usr/bin/env bash
,实际上,最好是为您的重启问题打开一个新问题。
您很可能不在重新启动命令所在的目录中
定义或重新启动不在您的路径中。尝试把整个路径。