Bash Script via Shell Command - Return Code 1

Hi All, thanks in advance for any help.

Trying to run a simple bash script using the shell command component but not having any luck. Seems to be plenty of other posts about this so I looked through them and seem to be able to rule out the most common factors like permissions issues but still can’t get it to work.

Rather than having everyone go over what I have and haven’t done, which may still be necessary, I wanted to check and see if anyone knows the meaning of “return code 127” which I am seeing in the home-assistant.log file when I try to run this shell command.

I’ve been searching the web and this forum but can’t track down any explanation of what this code means. I’ve also seen “return code -11” before when testing different formatting for the shell command so if anyone knows what that means that might help too, thanks again.

Hi @sheller, take a look here and here.
Seems like HA can’t find your script or commands in the script.

Thanks, I didn’t realize it was just spitting out standard bash error codes, that makes sense. Still having some trouble though so maybe someone can help…

I can get simple scripts to run, like a script with just a touch command/etc, but the specific script I’m trying to run is now just returning exit code 1 in the home-assistant.log file. The script is stored in the homeassistant directory along with the configuration.yaml/etc files, permissions are all correct, and when running the script manually through the CLI it works properly with no errors.

The script runs and disables a camera in Synology Surveillance Station, the contents are:

wget -q --keep-session-cookies --save-cookies cam-cookies -O- “http://[IP and port]/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=1&account=[USER]&passwd=[PASSWORD]&session=SurveillanceStation”
wget -q --load-cookies cam-cookies -O- “http://[IP ADDRESS]/webapi/entry.cgi?cameraIds=4&api=SYNO.SurveillanceStation.Camera&version=8&method=Disable”
wget -q --load-cookies cam-cookies -O- “http://[IP ADDRESS]/webapi/auth.cgi?api=SYNO.API.Auth&method=Logout&version=1”
rm cam-cookies

Any obvious problems with this anyone can spot? Or are there any specific constraints on scripts that get run from HA?

Found a fix here in case this ends up being useful for anyone else. All I did was swap out wget with curl and it worked perfectly. No idea why that fixed it, I use a wget command for a switch in HA with no issue, but if you run into the same problem there’s your fix. cURL ftw