I am going crazy here, i've been struggling to get a script running from domoticz. I've been searching on this and other forums for a more than a day now, and I can't find the solution.
The script itself is running perfectly on command line. I made sure the owner and permissions are set to root.
For testing purposes , i've created a quite empty script called test.sh to see if that can be run correct, but it is running into the same errors.
Domoticz log:
2018-09-23 10:52:57.733 Error: Error executing script command (/home/pi/domoticz/scripts/test.sh#). returned: 32512
The script:<br/>
root@DomoControllerRPI3:/home/pi/domoticz/scripts# ls -l
-rwxrwxrwx 1 root root 177 Sep 23 10:44 test.sh
The reduced script:
Code: Select all
#!/bin/sh
LOGFILE=/home/pi/camerasnapshot.log
today=`/bin/date '+%d-%m-%Y__%H-%M-%S'`; #Used to generate filename
echo Test.sh has been executed $today |tee -a $LOGFILE
root@DomoControllerRPI3:/home/pi# ls -l
-rwxrwxrwx 1 root root 4321 Sep 23 10:44 camerasnapshot.log
The blockly script call: When i add a space and & it seems to work and domoticz executes the script. 2018-09-23 11:21:56.573 Status: Executing script: /home/pi/domoticz/scripts/test.sh &#[/b]
Then i tried to rebuild the script
The script will work until it needs to call the mailx command. to mail the attachments. I want to use mailx because I need multiple attachments to be sent as part of a security script. the script below seems to work now until the mailx command. I have a camerasnapshot in the correct location.
Code: Select all
#!/bin/sh
LOGFILE=/home/pi/camerasnapshot.log
today=`/bin/date '+%d-%m-%Y__%H-%M-%S'`; #Used to generate filename
echo Test.sh has been executed $today |tee -a $LOGFILE
IP="192.168.2.201" # IP address Camera echo $IP $today |tee -a $LOGFILE
# Ping IP-address of camera to see if it's online, otherwise we don't have to grab a snapshot
if ping -c 1 $IP > /dev/null ; then #Grab snapshot
echo camera online |tee -a $LOGFILE
#Get Snapshot from camera
wget "http://192.168.2.201:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=user&pwd=pass" -O /home/pi/Camera_Snapshots/WoonkamerCamera.jpeg
#echo start sending mail $today |tee -a $LOGFILE
echo "Beweging geconstateerd in de Woonkamer" | mailx -A gmail -s "Beweging in Woonkamer" [email protected]
else
echo camera onbereikbaar |tee -a $LOGFILE
fi
root@DomoControllerRPI3:/etc# mailx
No mail for root
When I run the script from CLI as root, its working perfectly:
Code: Select all
root@DomoControllerRPI3:/home/pi/domoticz/scripts# ./test.sh
Test.sh has been executed 23-09-2018__11-38-26
camera online
--2018-09-23 11:38:26-- http://192.168.2.201:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=user&pwd=password
Connecting to 192.168.2.201:88... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘/home/pi/Camera_Snapshots/WoonkamerCamera.jpeg’
/home/pi/Camera_Snapshots/WoonkamerCamera.jpeg [ <=> ] 51 --.-KB/s in 0s
2018-09-23 11:38:26 (434 KB/s) - ‘/home/pi/Camera_Snapshots/WoonkamerCamera.jpeg’ saved [51]
root@DomoControllerRPI3:/home/pi/domoticz/scripts#
I am at a complete loss here.
What am i missing? additional permissions needed for mailx and if so where should i set those?
Any help is appreciated