命令未找到或不可执行:.sh // /bin/chmod: No such file or directory

The command was not found or was not executable: .sh // /bin/chmod: No such file or directory

我正在尝试 运行 一个 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 显然不是可以传递给 shell/command.

的命令

要么直接传递命令完整路径:

- 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

解决了问题:chmod +x ./TPCxBB_Benchmarkrun.sh