Alright, so here's what I have:

I have a script, called detect.sh. This file is located in /home/pi/detect/detect.sh. It's permissions are: -rxwrxwrxw 1 motion motion 66 Feb 19 10:20 /home/pi/detect/detect.sh

This script, contains this code:

#!/bin/sh date >> /home/pi/detect/detect_log.txt python /home/pi/detect/detect.py

As you can see, this script executes my Python script.

My python script is located in /home/pi/detect/detect.py, as you can also see. My python script has the following permissions: -rwxrwxrwx 1 motion motion 178 Feb 19 10:28 /home/pi/detect/detect.py

My Python script contains the following code:

import os import subprocess text_file = open('/home/pi/Desktop/output.txt', 'w') text_file.write('Test 1') text_file.close() os.system("sudo aplay /home/pi/detect/bark.wav")

When I start motion, using sudo service motion restart , nothing happens. I have, in the configuration file for motion, to

on_event_start sh /home/pi/detect/detect.sh

I know this is working. Because my detect_log.txt is created AND updated correctly, which means my script is running. But my python script is not. I do not hear a dog bark, nor is a .txt file created.

Also, my Python script runs when I run it using the standalone module, using Python. I hear a bark and the file is created.

Is this a permissions issue? What is going on? Could it be a permissions for Python issue? I am thoroughly confused, and have been searching for an answer for weeks. Any help is appreciated.