Hello, I am trying to run a shell script from inside Octoprint. I have two .sh files for turning ON/OFF my LED strip on my printer. If I run it directly on the terminal, for example via Putty, it works just fine.
Now, I want to be able to call those two scripts from inside Octoprint through two different buttons.
I have searched for it and found two relevant posts about exactly my goal:
I have no idea where to look more. It works writing directly on the terminal via putty but not through OctoPrint.
I click on either button and nothing happens. I dont know exactly how to debug this as well.
Hello! Yes, you are right. Sorry, I updated an old version. Here is the one that is currently being used. config.yaml (3.5 KB)
It is there but still doesnt work.
One is a 'py' and one is a 'sh'... Which is fine if the files are written correctly. Have to see them to tell. You need 'shebangs' as the first line usually. The other thing is the execute bit has to be set.
Both are bash scripts that run a python script. I had less problems running it like this because I had another unrelated problem, I suppose, with pathing and enviroment. I suppose there is no difference for octoprint to run them? It could be either, right? Also the examples I found were with bash files.
they might work directly. that line is basically telling the file to use the OS level python file, which I assume is where you have your dependencies installed to get the python file to work manually.
Also, I put my scripts in the "/home/pi/.octoprint/scripts/" directory cause then OctoPrint Backup and Restore will - well - back them up and restore them...
By default linux does not give full access to a file, even the ability to run. I just give full access to everyone. At a command prompt, cd to the directory of the file and run this command;
chmod 777 'filename'
my assumption is that they created the file logged in as the user pi, which is the same user that OctoPrint is run with from the service configuration on an OctoPi setup.
I'm not as familiar with shebangs like some of these other guys are, but maybe it should be #!/usr/bin/env python3 instead. and then you test is with ./scripts/ledON.py from a SSH session.