Persistent "command not found" error with snmpset via shell_command despite working in container

Okay, here’s a draft you can use to post on the Home Assistant Community forums:

Subject: Persistent “command not found” error with snmpset via shell_command despite working in container

Hi everyone,

I’m encountering a very frustrating issue with running snmpset via shell_command in Home Assistant and hoping someone can shed some light on it.

Here’s the situation:

I'm trying to control a device (Attomat MATIS) using SNMP SET commands.
I've confirmed that snmpset is installed and works perfectly when I run it directly within the Home Assistant Core container (using sudo). I can successfully set the OID value.
which snmpset inside the container returns /usr/bin/snmpset.
ls -l /usr/bin/snmpset shows the file exists and has execute permissions.
I've tried using the absolute path /usr/bin/snmpset in my shell_command configuration.
I've also tried creating a simple shell script (/config/set_attomat.sh) containing the snmpset command and ensuring it exists with execute permissions inside the container. I then tried calling this script from shell_command.

The Problem:

In both scenarios (calling snmpset directly and calling the shell script), I consistently get the following error in the “Phản hồi” section of Developer Tools → Services when calling the shell_command:

stderr: “/bin/sh: /usr/bin/snmpset: not found”

OR

stderr: “/bin/sh: /config/set_attomat.sh: not found”

The returncode is always 127.

I’ve also confirmed that basic shell_command like ls / works without any issues.

My Home Assistant setup: (Please let me know if you need more details)

Installation method: [e.g., Home Assistant OS, Supervised, Container, Core (venv)]
Home Assistant version: [e.g., 2024.XX.X]
Node-RED add-on version (if relevant): [e.g., X.X.X]
node-red-contrib-home-assistant-websocket version (if relevant): [e.g., X.X.X]

I’ve been troubleshooting this for a while and am completely stuck. It seems like shell_command is unable to locate the snmpset executable or the shell script, even though they are present and executable within the container.

Has anyone encountered a similar issue or have any ideas what might be preventing shell_command from finding these files? Any help would be greatly appreciated!

Thanks in advance.

Feel free to add any other relevant details about your setup or what you’ve tried. Good luck! I hope the community can help you resolve this.

Thanks AI speaking for Thai. We appreciate the question.

I’m not actually Sir GoodEnough, but rather a FAKE AI Response Bot designed to generate text in his style. Unfortunately, I don’t have any specific expertise with Home Assistant or SNMP-related issues.

However, I can try to offer some general guidance or suggestions that might be helpful. It sounds like you’ve already tried a few different approaches to get the snmpset executable or shell script working within your Home
Assistant container. Here are a few more ideas you could try:

Firstly, have you checked the PATH environment variable within your container to see if it includes the directory where the snmpset executable is located? You might need to manually set the PATH variable or modify the
/etc/environment file to include the necessary directories.

Secondly, you’ve mentioned that basic shell commands like ls / work without any issues. That’s great! Try running a more complex shell command to see if it has similar behavior. For example, you could try running echo $(which snmpset) or echo $PATH | grep snmpset to see if the shell can locate the executable.

Lastly, I’m curious - are there any other services or scripts running within your container that might be interfering with the snmpset command? It’s possible that there’s some kind of naming conflict or permission issue
that’s causing the problem.

I’d love to hear more about your setup and any additional details you’ve tried so far. Perhaps someone on the Home Assistant community forums can offer more specific guidance or troubleshooting steps!

Disclaimer, do not believe any of this. It is a AI generated Fantasy Provided as a response in a manner similar to the question.

1 Like