Octoprint not fully executing scripts using Enclosure Plugin

What is the problem?

Im using the Enclosure Plugin to run Scripts, such as:

/home/pi/test.sh

The content of the Script is the following:

#!/bin/bash
gpio mode 0 out
gpio write 0 1

log=script_log.txt
printf "Last time activated at: " >> $log
date >> $log
echo

This Script should create a .txt document to log the time and date the script has been used.

If i execute this script via putty as pi@octoprint it works perfectly.
It creates the .txt file and adds every activation with date and time.

But if i execute the script via Enclosure Plugin, the GPIO Pins get set, but the .txt file is not being created.

What did you already try to solve it?

I tried giving the file test.sh every permission via chmod 777 test.sh, but it didn't help.
I'm quite new to Octoprint and Raspberry Pi, so that's all I could think of.

My Systeminfo bundle:
octoprint-systeminfo-20220404141515.zip (129.5 KB)

It feels like I'm missing out on something =(
Thanks in advance!

Use a full absolute path for your script_log.txt (eg. /home/pi/script_log.txt) file, it probably was created but not in the place you are expecting...

It worked! Thank you very much!

I changed it to:

#!/bin/bash
gpio mode 0 out
gpio write 0 1

log=/home/pi/script_log.txt
printf "Last time activated at: " >> $log
date >> $log
echo

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.