【发布时间】:2016-09-19 14:08:40
【问题描述】:
我对 linux 和 shell 脚本非常陌生。 我正在尝试使用以下命令从 linux 上的安全 shell (ssh) 运行 shellscript:
chmod +x path/to/mynewshell.sh
sh path/to/mynewshell.sh
我得到这个错误:
path/to/mynewshell.sh: path/to/mynewshell.sh: cannot execute binary file.
尝试使用此命令:
bash path/to/mynewshell.sh
我得到同样的错误。
尝试使用此命令:su - myusername sh path/to/mynewshell.sh
它要求我输入密码并给我这个错误:no such file or directory。
1. cat -v path/to/mynewshell.sh 的结果是: ^@^@^@^@^@^@^@^@Rscript "$dir"/diver_script.R 完成
2.当尝试'less path/to/mynewshell.sh'时,我在终端上得到了这个:
#!/bin/bash/Rscript^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
for dir in /path/to/* ; do
^@^@^@^@^@^@^@^@Rscript "$dir"/myRscript.R
done
3.当我运行文件 path/to/mynewshell.sh 时:我得到了这个“Bourne-Again shell script text executable”
请就如何尝试执行 shellscript 提供任何建议。
【问题讨论】:
-
是
/path/to/还是/path/toscript/?你似乎把它们弄混了。 -
试试
less path/toscript/mynewshell.sh看看这个文件是否真的是一个shell脚本。 -
编辑问题并添加
cat -v path/toscript/mynewshell.sh的结果。你是从windows系统导入这个脚本的吗?第一行是空的吗?否则它是否以 shebang 和有效命令开头? -
或者,运行
file path/toscript/mynewshell.sh并编辑您的问题以包含输出。 -
该脚本文件严重损坏。我们可以尝试猜测该文件中应该包含的内容,但如果您能找到它的原始来源并检索到未损坏的副本,那您会更好。