How to work with Gcode System Commands Properly

I am very new to most of this so please forgive my ignorance. Basically I am wanting to control a servo motor with a python program using the Gcode System Command. So what I did was proof out my python code so that it properly executes. It is located in /share/ I then created a .sh program that simply calls this python program and it's located in the same folder. I then assigned OCTO10 to /share/ & . This run on the terminal of Octoprint doesn't seem to modify the Servo position but when I am on CLI I try to run ./share/ and it says no attribute found. So then I "cd" into the /share folder and run ./ and it performs exactly as I would expect. So I am wondering how do I need to write these programs in order to get OCTO10 to work properly. It seems like nothing I am trying is having an effect. Below is my code:


sudo python3 /share/ &

any help would be much appreciated.

Do you have passwordless sudo configured? By default OctoPi does not and you need the password for most commands (there are exceptions for services and shutdown).

Test the script locally too.

I actually did get it to finally work. I found how to use my password in an echo statement to allow the "sudo" command and then I found that in the octoprint settings that I need to add it a little differently.

So my script looks like this:

echo <mypassword> | sudo python3 /share/ &

and my OCTO10 settings are simply

/share/ &

Holy cow, DO NOT DO THIS. Use sudo and the sudoers file, don't hard code your password in some random script :astonished: