Quantcast
Channel: Support - Pimoroni Buccaneers
Viewing all articles
Browse latest Browse all 6857

Automation Phat - permissions problem?

$
0
0

@Rspamders wrote:

Hi.

I have an automation Phat which is working well. When I click a button on a simple php webpage - hosted on a local Apache 2 server, I am trying to get 2 things to happen:

  1. A Prowl notification is sent to my phone (this works fine)
  2. The Automation Phat relay to be toggled (this doesn’t work and causes an entry in the apache error.log below)

How I set it up:

This php code fragment calls a shell script

<?php
        if(isset($_GET['trigger']) && $_GET['trigger'] == 1) {
                error_reporting(E_ALL);
                $command = escapeshellcmd('/var/www/html/GDRelayToggle.sh');
                $output = shell_exec($command);
                echo $output;
        }
?>

GDRelayToggle.sh consists very simply of:

#!/bin/bash
python  /var/www/html/GDRelayToggle.py > /dev/null

GDRelayToggle.py is a simple sequence:

#!/usr/bin/env python
import time
import automationhat
from subprocess import call
call('/home/pi/prowl.pl -apikeyfile=/home/pi/prowl_key.txt -event="G DOOR ALERT" -notification="GD Motor" -priority=2', shell=True)
automationhat.relay.one.toggle()
time.sleep(0.3)
automationhat.relay.one.toggle()

In /var/log/apache2/error.log

Traceback (most recent call last):
  File "/var/www/html/GDRelayToggle.py", line 6, in <module>
    automationhat.relay.one.toggle()
  File "/usr/lib/python2.7/dist-packages/automationhat/__init__.py", line 238, in toggle
    self.write(not self.read())
  File "/usr/lib/python2.7/dist-packages/automationhat/__init__.py", line 143, in read
    self.setup()
  File "/usr/lib/python2.7/dist-packages/automationhat/__init__.py", line 259, in setup
    setup()
  File "/usr/lib/python2.7/dist-packages/automationhat/__init__.py", line 354, in setup
    _ads1015 = ads1015(smbus.SMBus(1))
IOError: [Errno 13] Permission denied

I tried chmod and chown the 2 scripts as follows…

-rwxr-xr-x 1 root root   297 Jun 11 21:18 GDRelayToggle.py
-rwxr-xr-x 1 root root    64 Jul 14 17:47 GDRelayToggle.sh

Run on their own - the shell script or the python code run correctly (phone alert and relay toggles on/off).

Any idea why activating these from the apache web server are causing the IOError: [Errno 13] Permission denied?

Suggestions would be most welcome - hope my first post to this forum makes sense.

Thanks,

Rob

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6857

Trending Articles