Page 1 of 1

Scripts doesn't work in domoticz

Posted: Tuesday 04 April 2017 23:55
by marcotrumpet
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.

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 0:25
by kubrik
If you run in terminal:

Code: Select all

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

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 6:31
by marcotrumpet
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

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 7:16
by jannl
Can the script find vlc when started from domoticz?

Verstuurd vanaf mijn SM-G930F met Tapatalk

Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 7:17
by marcotrumpet
I don't know. How can I know if it does?


Inviato dal mio iPhone utilizzando Tapatalk

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 8:22
by Egregius
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
...

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 8:23
by kubrik
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?

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 10:24
by marcotrumpet
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

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 10:27
by marcotrumpet
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

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 13:41
by kubrik
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...

..

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 13:51
by marcotrumpet
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?

Re: Scripts doesn't work in domoticz

Posted: Wednesday 05 April 2017 13:57
by marcotrumpet
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

Scripts doesn't work in domoticz

Posted: Friday 07 April 2017 14:55
by marcotrumpet
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

Re: Scripts doesn't work in domoticz

Posted: Saturday 08 April 2017 11:37
by marcotrumpet
Done. Simply add an & at the end of the scripts.


Inviato dal mio iPhone utilizzando Tapatalk

Re: Scripts doesn't work in domoticz

Posted: Sunday 08 March 2020 12:30
by Justintime
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...

..
Thanks the golden tip.