Scripts doesn't work in domoticz

Post Reply
marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Scripts doesn't work in domoticz

Post by marcotrumpet » Tuesday 04 April 2017 23:55

Hey guys, I've a problem.

I wrote a script.sh and it works really well in terminal. I set a dummy switch and in the on action I set the script.

Code: Select all

#!/bin/sh

# Start Recording RTSP stream via VLC

vlc rtsp://192.168.1.3/unicast --sout=file/mp4:/home/pi/Desktop/Soggiorno-$(date +%m%d%H%M%S).mp4 -I dummy --stop-time=10 vlc://quit

exit 0
that's the script. Already set chmod 777 script.sh and chmod +x script.sh.

In domoticz log I see

Code: Select all

Executing script: /home/pi/domoticz/scripts/soggiorno.sh
and no error but nothing happens.

kubrik
Posts: 54
Joined: Wednesday 30 November 2016 16:07
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by kubrik » Wednesday 05 April 2017 0:25

If you run in terminal:

Code: Select all

sudo /home/pi/domoticz/scripts/soggiorno.sh
it works?

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by marcotrumpet » Wednesday 05 April 2017 6:31

kubrik wrote:If you run in terminal:

Code: Select all

sudo /home/pi/domoticz/scripts/soggiorno.sh
it works?
Yes it works


Inviato dal mio iPhone utilizzando Tapatalk

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Scripts doesn't work in domoticz

Post by jannl » Wednesday 05 April 2017 7:16

Can the script find vlc when started from domoticz?

Verstuurd vanaf mijn SM-G930F met Tapatalk

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Scripts doesn't work in domoticz

Post by marcotrumpet » Wednesday 05 April 2017 7:17

I don't know. How can I know if it does?


Inviato dal mio iPhone utilizzando Tapatalk

User avatar
Egregius
Posts: 2667
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Scripts doesn't work in domoticz

Post by Egregius » Wednesday 05 April 2017 8:22

Use the absolute path to executables.
Make sure the users that run's Domoticz has rights to the scripts and executables.
Add a echo 'script executed' > /temp/test.log to see of the script is called from domoticz
...

kubrik
Posts: 54
Joined: Wednesday 30 November 2016 16:07
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by kubrik » Wednesday 05 April 2017 8:23

Try to put output to logfile...for example:

Code: Select all

vlc rtsp://192.168.1.3/unicast --sout=file/mp4:/home/pi/Desktop/Soggiorno-$(date +%m%d%H%M%S).mp4 -I dummy --stop-time=10 > /home/pi/domoticz/scripts/vlc.log
and look into vlc.log after execution.
A question...but with that vlc command...vlc opens graphically into your desktop?

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by marcotrumpet » Wednesday 05 April 2017 10:24

kubrik wrote:Try to put output to logfile...for example:

Code: Select all

vlc rtsp://192.168.1.3/unicast --sout=file/mp4:/home/pi/Desktop/Soggiorno-$(date +%m%d%H%M%S).mp4 -I dummy --stop-time=10 > /home/pi/domoticz/scripts/vlc.log
and look into vlc.log after execution.
A question...but with that vlc command...vlc opens graphically into your desktop?
Log file is empty.

if I start the script in terminal vlc doesn't open graphically

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by marcotrumpet » Wednesday 05 April 2017 10:27

marcotrumpet wrote:
kubrik wrote:If you run in terminal:

Code: Select all

sudo /home/pi/domoticz/scripts/soggiorno.sh
it works?
Yes it works

EDIT
I'm sorry I was wrong. If I use SUDO I recive this "VLC is not supposed to be run as root. Sorry.
If you need to use real-time priorities and/or privileged TCP ports
you can use vlc-wrapper (make sure it is Set-UID root and
cannot be run by non-trusted users first)."

Nut starts fine without SUDO

Inviato dal mio iPhone utilizzando Tapatalk

kubrik
Posts: 54
Joined: Wednesday 30 November 2016 16:07
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by kubrik » Wednesday 05 April 2017 13:41

Domoticz on raspberry runs as root..so scripts run as root...

You can try this:

Code: Select all

sed -i 's/geteuid/getppid/' /usr/bin/vlc
(rif. http://unix.stackexchange.com/questions ... er-in-root)

and run again as root...but make a backup of /usr/bin/vlc before...

Or recompile vlc...

Or use avconf instead of vlc...

..

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by marcotrumpet » Wednesday 05 April 2017 13:51

kubrik wrote:Domoticz on raspberry runs as root..so scripts run as root...

You can try this:

Code: Select all

sed -i 's/geteuid/getppid/' /usr/bin/vlc
(rif. http://unix.stackexchange.com/questions ... er-in-root)

and run again as root...but make a backup of /usr/bin/vlc before...

Or recompile vlc...

Or use avconf instead of vlc...

..
Yes man! you did it! but now I'm not able to open file due to permission I think.
How can I set permission on file that has (date +%m%d%H%M%S) in the name?

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by marcotrumpet » Wednesday 05 April 2017 13:57

marcotrumpet wrote:
kubrik wrote:Domoticz on raspberry runs as root..so scripts run as root...

You can try this:

Code: Select all

sed -i 's/geteuid/getppid/' /usr/bin/vlc
(rif. http://unix.stackexchange.com/questions ... er-in-root)

and run again as root...but make a backup of /usr/bin/vlc before...

Or recompile vlc...

Or use avconf instead of vlc...

..
Yes man! you did it! but now I'm not able to open file due to permission I think.
How can I set permission on file that has (date +%m%d%H%M%S) in the name?
It seems that change permission to folder did the trick

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Scripts doesn't work in domoticz

Post by marcotrumpet » Friday 07 April 2017 14:55

Just another problem. I've two scripts calling vlc to record two cameras but domoticz doesn't run them at the same time. If I open two terminals and lunch one script per istance I can do that. I also enabled multiple istances on vlc. Ideas?


Inviato dal mio iPhone utilizzando Tapatalk

marcotrumpet
Posts: 118
Joined: Saturday 18 February 2017 9:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by marcotrumpet » Saturday 08 April 2017 11:37

Done. Simply add an & at the end of the scripts.


Inviato dal mio iPhone utilizzando Tapatalk

Post Reply

Who is online

Users browsing this forum: ala666cz and 1 guest