Help with command_line sensor to execute shell script

Hi all - I’m tearing my hair out trying to setup a simple command_line sensor, which executes a script to retrieve it’s value.

I’ve configured the sensor like below and have my_script.sh located in my home assistant /config directory.

- platform: command_line
  name: my_script_name
  command: "my_script.sh"

However, the sensor always fails with the following error:

/bin/sh: my_script.sh: not found
2020-08-16 19:06:05 ERROR (SyncWorker_1) [homeassistant.components.command_line] Command failed: my_script.sh

If I change the command to pwd or ls I can see the working directory for the command is /config and in the ls output I can see my_script.sh listed. I’m clearly missing something very basic here. Note - I’m running home assistant in docker under Ubuntu if that’s important.

Any help or pointers would be much appreciated. Thanks in advance!

Dave

Have you set the file’s permissions to include execution?

Yep, it’s been chmod a+x. Note - I can run it myself on the command line without issue

Is there some sort of typo involved here?

The first line of the error message you posted indicates my_scipt.sh which lacks an r in the word script.

Or is it just a copy-paste error?

Sorry, the script is actually named something else. That’s just a typo in my effort to sanitize for my post here. The real script name matches up with filename in sensor config.

Hello, did you ever find a solution. I am having the same issue. I can run it manually but does not run as a command_line sensor via YAML

What about the

"/full/path/to/my_script.sh"

?

@HomeTheatersRock I’m afraid I was never able to get it working…