找不到命令或命令不可执行:.sh // / bin / chmod:没有这样的文件或目录

时间:2020-04-12 13:48:09

标签: shell ansible benchmarking

我正在尝试运行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"

有人知道可能是什么问题吗?

2 个答案:

答案 0 :(得分:1)

chdir=/home/cloudera/Documents/TPCx-BB/bin/TPCxBB_Benchmarkrun.sh显然不是可以传递给Shell /命令的命令。

直接传递命令完整路径:

- 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

答案 1 :(得分:0)

使用以下命令解决了该问题:chmod + x ./TPCxBB_Benchmarkrun.sh