Announcement

Collapse
No announcement yet.

HS3 Pi will run program, Web server only gets halfway!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    HS3 Pi will run program, Web server only gets halfway!

    On the Pi I am using to run HS3 I have setup a shell script to take a photo using raspistill, then run another python program which emails it to me. When run from the Pi, logged in as pi, the photo is stored in /home/pi and everything works fine. If I set the script up to run as an event in HS3, I can see the photo is taken and stored, but it is not emailed. I can’t help thinking this is some kind of permissions issue - the photo is owned by root, and pi is a member of the sudo group. If I change the program so it is stored in /home/homeseer then I cannot run the program as pi any more. But I still can’t run the event from HS3!

    What am I missing? Please help, this is driving me mad! It’s a clone of something I have set up on a different system, which works fine. I don’t know if it might be something to do with web user access rights to HS3, I admit I don’t understand that at all.

    #2
    Since HS3 runs as root, it has all the permissions it needs on the local machine.

    Check that the script you are running is running with an appropriate working directory. When executed from an event, the working directory will most likely be the HS3 root directory. When running as pi its likely pi's home directory or a subdirectory of that.

    Comment


      #3
      Originally posted by zwolfpack View Post
      Since HS3 runs as root, it has all the permissions it needs on the local machine.

      Check that the script you are running is running with an appropriate working directory. When executed from an event, the working directory will most likely be the HS3 root directory. When running as pi its likely pi's home directory or a subdirectory of that.
      Hi, thanks for your reply. The shell script and python program it calls are both in /home/homeseer/scripts. That’s where I’ve told the HS3 event to run it from, and in a different HS3 installation that I have cloned these scripts from, it works. I’ll try putting them in the root directory tomorrow, but the script runs from where it is now - if I run the event to run the script the camera light flashes and the picture taken shows on the Pi’s monitor - but it looks like the python programme that emails the picture can’t access it. And remember that program is in the same directory as the script.

      If HS3 has all the privileges that pi has on the command line then why do both the script and program it calls run for pi but the script fails to call the program (or the program doesn’t complete) for HS3? It’s bizarre (to me!)

      Comment


        #4
        You can add this at the beginning of a shell script to send all output (standard and error) to a log file

        logfile=/tmp/xyz.log
        exec > $logfile 2>&1

        Hopefully that will provide some clue.

        Comment


          #5
          Got it, eventually. I hadn’t put the full path to the python program in the shell script. When I tested it from the Pi I just happened to be in the directory where script and program are, so it worked. And although I gave HS3 the full path to the script, I had forgotten that it wouldn’t automatically look in the same directory for the python program. Now I feel stupid and happy at the same time!

          Comment

          Working...
          X