I am trying to create a control button that runs a python script located on my raspberry pi 4 using GCODE System Commands, but I am unable to get the script to run from the button. I also am unsure of how to properly display the terminal output.
What did you already try to solve it?
I have tried rewriting the pathing and taken a look at similar topics, but I cannot get the button to function properly. I also am unaware of how to format the output properly based on the information given by the config.yaml information page.
I am unable to type into the terminal, I am currently running the octopi disconnected from the printer as I do not have access to it due to covid restrictions. I am trying to build a plugin that will output sensor data connected to the pi so I have been working it it separate from the printer in the meantime. I will attempt to connect it to a printer in a few hours and see if that resolves the issue.
Thank you, I was unaware of this. This resolved the issue I was having regarding not being able to press the button, but I am now getting an error within the terminal when the command is called.
This is my current command definition, I believe it is pathed correctly as if I type this command within the terminal on remote desktop I get a terminal readout that I would expect but it is not functioning and returning that error.
sometime you have to put the interpreter for the file at the top and chmod +x it to make it executable maybe? so something like #!/usr/bin/python3 as the first line of your py file. or are you using a sh script? The important part that the command is configured with the full path to the file as well in the plugin's settings.
I added the suggested line to the code, added the file to chmod +x, but am still getting the same error. The command is shown below, I am trying to run a .py file.
That is probably the issue. I don't think you can sudo with the plugin unless you add a sudoers rule to the OS, but @kantlivelong would have to confirm. With adding those previous bits and making it executable you shouldn't need the python3 command at all I don't think. Does the python file require root access to properly run?
I've looked through that thread and recreated the test files you gave, and I am still getting an error from the octoprint terminal. I've used the chmod +x test.sh command, but running sh test.sh does not return any output or error, I am unsure what I am doing wrong.
I am at my wits end, I have all files running properly through the terminal from remote desktop, but I am returning an error instead of printing from the terminal. My programs are:
The adafruit_adxl34x library is installed at /usr/local/lib/python3.7/dist-packages
This is what is returned from the octoprint.log:
2022-01-26 00:12:54,934 - octoprint.plugins.gcodesystemcommands - DEBUG - Command ID=01, Line=/home/pi/test.sh, Args=None
2022-01-26 00:12:54,934 - octoprint.plugins.gcodesystemcommands - INFO - Executing command ID: 01
2022-01-26 00:12:54,990 - octoprint.plugins.gcodesystemcommands - DEBUG - Command ID 01 returned: 127, output=b'/bin/sh: 1: /home/pi/test.sh: not found\n'
2022-01-26 00:12:54,991 - octoprint.plugins.gcodesystemcommands - INFO - Command ID 01 returned: 127
This is suggesting the wrong path is configured for the script? It is saying /home/pi/test.sh, above you wrote the file name as ADXLrun.sh. so then the error below is saying it can't find that file.