shell - 该命令未找到或不可执行:.sh // /bin/chmod: 没有这样的文件或目录
问题描述
我正在尝试运行 shell 脚本并出现错误:
"The command was not found or was not executable: chdir=/home/cloudera/Documents/TPCx-BB/bin/TPCxBB_Benchmarkrun.sh."
该脚本位于此文件夹中,因此它必须是不可执行的。它具有以下权限:
chmod 777 -R /home/cloudera/Documents/TPCx-BB/bin/TPCxBB_Benchmarkrun.sh
脚本开始于:
#!/usr/bin/env bash
我从 ansible 运行它,如下所示:
command: chdir=/home/cloudera/Documents/TPCx-BB/bin/TPCxBB_Benchmarkrun.sh
我找到了一个可能的解决方案来运行这样的命令:
但后来我收到以下错误:
"/bin/chmod: cannot access 'chdir=/home/cloudera/Documents/TPCx-BB/bin/TPCxBB_Benchmarkrun.sh': No such file or directory"
任何人都看到可能是什么问题?
解决方案
chdir=/home/cloudera/Documents/TPCx-BB/bin/TPCxBB_Benchmarkrun.sh
显然不是您可以传递给外壳/命令的命令。
直接传递命令完整路径:
- name: run my command
command: /home/cloudera/Documents/TPCx-BB/bin/TPCxBB_Benchmarkrun.sh
或chdir
正确使用该选项:
- name: run my command
command: ./TPCxBB_Benchmarkrun.sh
args:
chdir: /home/cloudera/Documents/TPCx-BB/bin
有关更多信息和示例:https ://docs.ansible.com/ansible/latest/modules/command_module.html
推荐阅读
- javascript - (javascript) JSON.parse() 改变 json 的内容
- javascript - 使用 redux 删除项目
- mysql - 如何过滤“SHOW BINLOG EVENTS”的输出
- reactjs - 使用 webpack 进行微前端开发
- r - 带有 heatmap.2() 函数的两个不同颜色键的热图
- python - Python Keras 循环 Lambda 层
- flutter - 如何通知 Android 媒体商店 Flutter 中的新文件
- python-3.x - 使用`yield`的Python生成器没有产生预期的结果
- c++ - std::is_same 的编译错误用法
- python - KeyError:“['something''something'] 不在索引中”