Page 1 of 1
How to see if script is running?
Posted: Friday 05 February 2016 22:47
by Evelen
Hi, just got my MiLights up, and wanted to try this script:
http://www.domoticz.com/forum/viewtopic.php?f=23&t=3402
So i saved the script in home/flemmingss/domoticz/script/wake_me_up_light.sh on the server (ubuntu server).
Also installed Netcat
Than I made a dummy switsh named "start wake_me_up_light.sh" with on-action:
script://home/flemmingss/domoticz/scripts/wake_me_up_light.sh
but nothing happening if i start it.
How can I see if scripts is running?
(So i can see if the problem is the script, og if it is that the script is not started).
Never started scripts before, just used blockly.
Logg:
Code: Select all
2016-02-05 22:40:45.277 User: flemmingss initiated a switch command
2016-02-05 22:40:45.277 (Dummy) Lighting 2 (start wake_me_up_light.sh)

Re: How to see if script is running?
Posted: Friday 05 February 2016 23:00
by Egregius
You could add a echo line to the script.
replace
Code: Select all
function verzend(){
echo -n -e $SENDCOM | nc -u -q 1 $IP $PORT
sleep $RUNTIME
}
with
Code: Select all
function verzend(){
echo -n -e $SENDCOM | nc -u -q 1 $IP $PORT
echo $(date +"%Y-%m-%d %H:%M:%S") : $SENDCOM >> /var/log/script.log
sleep $RUNTIME
}
Re: How to see if script is running?
Posted: Friday 05 February 2016 23:32
by Evelen
same result.
also no script.log in var/log/

Re: How to see if script is running?
Posted: Friday 05 February 2016 23:50
by Egregius
I now see that you only have 2 // instead of 3
2 // = relative to domoticz scripts folders
3 /// = absolute path
script://home/flemmingss/domoticz/scripts/wake_me_up_light.sh
script:///home/flemmingss/domoticz/scripts/wake_me_up_light.sh
Also, I believe it should be in the domoticz logfile. Something like executing script /home/flemmingss/domoticz/scripts/wake_me_up_light.sh
Is the script executable for the user domoticz runs?
Re: How to see if script is running?
Posted: Friday 05 February 2016 23:58
by Evelen
Now I got this:
Code: Select all
2016-02-05 23:56:56.125 User: flemmingss initiated a switch command
2016-02-05 23:56:56.125 (Dummy) Lighting 2 (start wake_me_up_light.sh)
2016-02-05 23:56:56.360 Executing script: /home/flemmingss/domoticz/scripts/wake_me_up_light.sh
2016-02-05 23:56:56.362 Error: Error executing script command (/home/flemmingss/domoticz/scripts/wake_me_up_light.sh). returned: 32256
"Is the script executable for the user domoticz runs?"
I don't know, how do i check?
Re: How to see if script is running?
Posted: Saturday 06 February 2016 6:42
by Egregius
ls -l /home/flemmingss/domoticz/scripts/wake_me_up_light.sh
should have x in the output:
-rwxr--r-- 1 pi pi 464 Jan 17 22:51 wake_me_up_light.sh
x = executable
if not:
chmod +x wake_me_up_light.sh
https://www.google.be/?gws_rd=ssl#q=mak ... able+linux
Re: How to see if script is running?
Posted: Saturday 06 February 2016 8:58
by oliviers
This looks like a long-running script. Domoticz doesn't like that. Scripts should be as quick as possible.
The way to go: Write two scripts:
The first one, which you will assign to "action on", will execute quickly (as to avoid disturbing Domoticz), and will just launch the second script, in background, with all your other commands, delays, etc:
The (very simple) first script will look like:
Code: Select all
#!/bin/bash
/home/pi/domotics/scripts/wake_me_up_light.sh & <== Please note the "&" (ampersand) which will ensure that 'wake_me_up_light.sh ' is launched in background, thus allowing this script to proceed and complete without waiting
Hope this helps,
Oliviers
Re: How to see if script is running?
Posted: Saturday 06 February 2016 16:18
by Evelen
oliviers : Is this a script O make to start the orginal script?
Re: How to see if script is running?
Posted: Saturday 06 February 2016 16:52
by Egregius
the script isn't executable. Run this command:
chmod +x /home/flemmingss/domoticz/scripts/wake_me_up_light.sh
But, as Oliviers said, place another script in between.
Something like /home/flemmings/domoticz/scripts/wake_me_up_light_exe.sh
with this content:
Code: Select all
#!/bin/bash
/home/pi/domotics/scripts/wake_me_up_light.sh &
Then put script:///home/flemmings/domoticz/scripts/wake_me_up_light_exe.sh in the action of the switch.
With this script in between, domoticz can continue instantly because the _exe script starts the real script in the background.