Trying to execute a script inside Octoprint

What is the problem?

I am trying to create a batch file to set gpio pin high (which will turn off power to the printer. I am putting the batch file (name sdown.sh) in the Octoprint Settings->Octoprint->Server->-Shutdown System, but the batch file never gets executed.
The sdown.sh (in my home directory) file contains:

#!/bin/bash
raspi-gpio set 27 op
raspi-gpio set 27 dh
sudo shutdown -h now

And I created it with nano on the Pi.

What did you already try to solve it?

  1. Manually ran sdown.sh (which is in my home directory), and it worked fine.
  2. Tried various combinations of sdown.sh in the Shutdown System field, but nothing worked.

I am a complete newbe on Linux. This used to work many years ago, and I rebuilt the Octoprint box to incorporate the Pi 7" touchscreen (so I could have local control over the printer), and now it doesn't work.

Have you tried running in safe mode?

Yes

Did running in safe mode solve the problem?

No. Batch file never got executed.

Systeminfo Bundle

You can download this in OctoPrint's System Information dialog ... no bundle, no support!)

octoprint-systeminfo-20240209015549.zip (44.5 KB)

Additional information about your setup

Octoprint on a Pi4B with 7" touch screen and custom hat. Driving the Pi with a 24V power supply with a buck converter 24V->5V. Printer is Prusa MK4 GPIO pin 27 drives the reset (through a relay on the hat-the relay is driven by a darlington transistor) on a high-power latching relay which cuts off power after 20 seconds to the Pi and the printer.

WRITE HERE

make sure you are doing full path to the file.

/home/pi/sdown.sh

That didn't work. Script never executed.

curious if you did chmod +x sdown.sh to make the script executable?

Of course. Didn't help.

try;
CHMod 777 /full path/sdown.sh

I had the incorrect path to sdown.sh in the shutdown field.

1 Like