View Single Post
nonsuch's Avatar
Posts: 584 | Thanked: 1,550 times | Joined on Sep 2019
#484
Progress.
The command script now executes. I had to use the full path when calling it.

I had to change the script so that it takes a START and STOP option, and added full paths to all commands just to be sure, as well as some narrative for the logs:
Code:
#!/bin/bash

exec > "$HOME/situations/situations-batterybuddy.txt" 2>&1

whoami
date
echo $1

sleep 5

case $1 in
START)
if /sbin/pidof harbour-batterybuddy-daemon ; then
        echo "no action, harbour-batterybuddy-daemon is already running"
else
    	echo "launching harbour-batterybuddy-daemon"
        /usr/bin/harbour-batterybuddy-daemon & disown
fi
;;
STOP)
if /sbin/pidof harbour-batterybuddy-daemon; then
        echo "killing harbour-batterybuddy-daemon"
        /usr/bin/killall -vw harbour-batterybuddy-daemon
else
    	echo "not killing harbour-batterybuddy-daemon because it is not running"
fi
;;
esac
But harbour-batterybuddy-daemon neither starts nor stops, even though this works when the script is executed manually, as a normal user.

When executed manually, "$HOME/situations/situations-batterybuddy.txt" contains:
Code:
nemo
Fri Aug 28 08:18:54 EEST 2020
STOP
25045
killing harbour-batterybuddy-daemon
Killed harbour-batterybuddy-daemon(25045) with signal 15
When executed through Situations, "$HOME/situations/situations-batterybuddy.txt" contains:
Code:
nemo
Fri Aug 28 08:18:54 EEST 2020
STOP
I am stumped.

PS: this is academic; at this point itwould be much more practical to just leave BatteryBuddy running and do its thing without help from Situations, but I want to know why the Command plugin isn't doing what I think it should.
__________________
N900 in 2020
SFOS in 2021