首页 > 解决方案 > 该命令未找到或不可执行:.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"

任何人都看到可能是什么问题?

标签: shellansiblebenchmarking

解决方案


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


推荐阅读