Sh script problem

What is the problem?

  • .sh script for light does not work in Octoprint . Im new to Octoprint.

What did you already try to solve it?
i tried the system command editor and custom control editor but am i doing something wrong?
I can call the script in /home/pi/ with "bash toogleLight.sh" via an SSH connection and it works too(can turn it on or off).

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, what kind of hardware precisely, ...)
OctoPrint 1.4.2
Python 2.7.16
OctoPi 0.17.0

my script looks like this:
#!/bin/bash

gpio mode 24 out

if [ $(gpio read 24) = 0 ]
then
gpio write 24 1
else
gpio write 24 0
fi

Try specifying the full command to bash - /bin/bash rather than just bash. Not sure how the custom controls are running, but I have found cases this is needed.

does not work that way either. I've tried different spellings.If I try it via the system command editor, it doesn't matter what I do, the same error occurs.

404 Not Found

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

afaik you may not actually need to specify /bin/bash or bash for the script.

Make sure the script file is executable with chmod +x /home/pi/toggleLight.sh.

The execution should then work just fine.

If it still doesn't work, it could be a user permissions issue - maybe OctoPrint is trying to run it as a user that isn't pi? In that case you may need to look into setting up sudo to not check a password for that script. Look at this Ubuntu sudoers thread for how best to set that up.

1 Like