OctoPrint-Enclosure icon indicating copy to clipboard operation
OctoPrint-Enclosure copied to clipboard

Output shell script

Open BoergiM87 opened this issue 3 years ago • 8 comments

Describe the bug Hi, if I create an output "shell script" with the path to the script and execute it, the whole webinterface does not react anymore and I have to restart the PI.

To Reproduce Steps to reproduce the behavior:

  1. Create a output "shell script" with the path of it
  2. Click on the execute bottom of the output
  3. See error

Additional context Bildschirmfoto 2020-12-28 um 22 38 47

BoergiM87 avatar Dec 28 '20 21:12 BoergiM87

I am doing pretty much the same, except with python scripts and not having any issues...

Does you shell script execute when called directly from a terminal ? It also depends what your script contains... B1868D46-72F4-4DEF-8539-EA718EFE395C

SaKiEQ avatar Jan 05 '21 19:01 SaKiEQ

I have test it to with a python script, but the same problem. Octoprint hangs completely and you have to restart the Pi.

Over the terminal i can execute the script with no errors.

This is the script:

import requests
url = 'XY'
headers = {
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'X-Requested-With': 'XMLHttpRequest',
    'Content-Type': 'application/json; charset=UTF-8'
}
payload = ''
r = requests.post(url, data=payload, headers=headers)
print r

BoergiM87 avatar Jan 05 '21 20:01 BoergiM87

I was having this issue with octoprint hanging. Now I recreated everything and it doesn't hang, but also doesn't work... :/

I create a script with a just an echo 'test' and it doesn't output anything....

image

luizbgomide avatar Feb 28 '22 14:02 luizbgomide

@luizbgomide Shell script is only supposed to run the script, not to output anything that it spits out. https://github.com/vitormhenrique/OctoPrint-Enclosure/blob/master/octoprint_enclosure/init.py#L534

vitormhenrique avatar Feb 28 '22 17:02 vitormhenrique

@BoergiM87 that is a PYTHON script, and this is not supposed to run a PYTHON script, only a SHELL script. Unless you call it with a python before it will never work.

vitormhenrique avatar Feb 28 '22 17:02 vitormhenrique

@vitormhenrique my issue was that it doesn't seem like the script was actually running. In the end I removed all my settings and recreated the call to the scripts and it worked... I'm really not sure of why it didn't work before.

I'm using that to trigger PSU Control, only because it has a dedicated icon on Printoid, otherwise it could have managed it entirely in your plugin...

luizbgomide avatar Feb 28 '22 20:02 luizbgomide

@vitormhenrique my issue was that it doesn't seem like the script was actually running. In the end I removed all my settings and recreated the call to the scripts and it worked... I'm really not sure of why it didn't work before.

I'm using that to trigger PSU Control, only because it has a dedicated icon on Printoid, otherwise it could have managed it entirely in your plugin...

@luizbgomide Did you ever figure out what the problem was besides removing your settings and re-creating them? I'm having the same issue trying to call:

curl -s -H "Content-Type: application/json" -H "X-Api-Key: YOUR_API_KEY" -X POST -d '{ "command":"turnPSUOn" }' http://YOUR_OCTOPRINT_SERVER/api/plugin/psucontrol

I created a script to touch a file which works, but doesn't like the above line.

DiP-ER avatar Jan 18 '23 15:01 DiP-ER

@DiP-ER no, no idea.

luizbgomide avatar Jan 18 '23 15:01 luizbgomide