Troubles running shell_command

Hi everyone, first post here!
I’m trying to define a shell_command to send a string through telnet to mi Opentherm Gateway.
This is what I put in configuration.yaml:

  set_outside_temp: '/bin/echo "OT=30.0" | /usr/bin/telnet 23"

The command works perfectly from command line, but not if I fire the shell_command from the “Services” page of the UI. Tried the combinations of single and double quotes as I could imagine, with no luck. In the log I get return code 127.

Any suggestion?

Well, right now, you have mismatched quotes. I’d try without the outside enclosing quotes. So:

  set_outside_temp: /bin/echo "OT=30.0" | /usr/bin/telnet 23

You’re right, actually is a mistake I made pasting in the post but it was rigth in the actual file. I also tried removing the outer quotes as you suggest, still get return code 127

Apparently status code 127 is a return code from bash that means command not found. I would try removing the second half of the command (i.e., the pipe and the telnet command) and see if just the echo command succeeds. If not, try without the full path (i.e., just echo …) That might give you further clues.

Getting closer… Activated logger to get more detailed log.
Running just the echo bit without the pipe to telnet works and returns code 0.
With the telnet command in the log I now see:

2018-08-21 15:46:40 DEBUG (MainThread) [homeassistant.components.shell_command] Stderr of command: `/bin/echo "OT=32.0" | /usr/bin/telnet 23`, return code: 127: b'/bin/sh: /usr/bin/telnet: not found\n'
2018-08-21 15:46:40 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `/bin/echo "OT=32.0" | /usr/bin/telnet 23`, return code: 127 NoneType: None


core-ssh:/config# which telnet

Try doing that which command while running as homeassistant. I suspect it won’t find it. It’s probably a permissions thing.

I now realised that both echo and telnet are actually links to busybox executable:

lrwxrwxrwx    1 root     root            12 Jun  1  2017 /bin/echo -> /bin/busybox
lrwxrwxrwx    1 root     root            12 Jun  1  2017 /usr/bin/telnet -> /bin/busybox

Permission on busybox executable is:

-rwxr-xr-x    1 root     root        955912 May 23  2017 /bin/busybox

Regarding your other suggestion, there seems to be no homeassistant user in my system. It was installed more than one year ago, even if home assistant itself has been updated to latest version. Maybe time to reinstall also given the recent distribution change.

Posting again under this thread, for a different but seemingly related issue. Trying to setup a command line switch which launches a curl command, I get a similar error, while the same command from an ssh session works flawlessly.

Any idea? I still believe it might be a permission issue, but I absolutely don’t know how to verify or solve it

did you found a solution? , the problem still persists in my case . has issues with shell commands see

I wrap shell commands in python wrappers see