我对 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 done
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 提供任何建议。
原文由 R Bud 发布,翻译遵循 CC BY-SA 4.0 许可协议
chmod -x
从文件中删除执行权限。做这个:并运行它
正如错误报告所说,你的脚本实际上不是一个脚本,它是一个二进制文件。