Scripts doesn't work in domoticz

Moderator: leecollings

Post Reply
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Scripts doesn't work in domoticz

Post 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.
kubrik
Posts: 47
Joined: Wednesday 30 November 2016 15:07
Target OS: Linux
Domoticz version: 2020.2
Location: Italy
Contact:

Re: Scripts doesn't work in domoticz

Post by kubrik »

If you run in terminal:

Code: Select all

sudo /home/pi/domoticz/scripts/soggiorno.sh
it works?
Ubuntu 20.04 on ACEPC AK1 (previously RPi3b+)
Z-Stick Gen5, RFXtrx433E, Philips HUE Bridge, Yeelight, ESP8266 NodeMCU, Broadlink RM
dZvents, bash, php, Node-RED
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post 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
jannl
Posts: 638
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Scripts doesn't work in domoticz

Post by jannl »

Can the script find vlc when started from domoticz?

Verstuurd vanaf mijn SM-G930F met Tapatalk
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Scripts doesn't work in domoticz

Post by marcotrumpet »

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


Inviato dal mio iPhone utilizzando Tapatalk
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Scripts doesn't work in domoticz

Post 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
...
kubrik
Posts: 47
Joined: Wednesday 30 November 2016 15:07
Target OS: Linux
Domoticz version: 2020.2
Location: Italy
Contact:

Re: Scripts doesn't work in domoticz

Post 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?
Ubuntu 20.04 on ACEPC AK1 (previously RPi3b+)
Z-Stick Gen5, RFXtrx433E, Philips HUE Bridge, Yeelight, ESP8266 NodeMCU, Broadlink RM
dZvents, bash, php, Node-RED
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post 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
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post 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
kubrik
Posts: 47
Joined: Wednesday 30 November 2016 15:07
Target OS: Linux
Domoticz version: 2020.2
Location: Italy
Contact:

Re: Scripts doesn't work in domoticz

Post 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...

..
Ubuntu 20.04 on ACEPC AK1 (previously RPi3b+)
Z-Stick Gen5, RFXtrx433E, Philips HUE Bridge, Yeelight, ESP8266 NodeMCU, Broadlink RM
dZvents, bash, php, Node-RED
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post 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?
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post 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
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Scripts doesn't work in domoticz

Post 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
marcotrumpet
Posts: 102
Joined: Saturday 18 February 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripts doesn't work in domoticz

Post by marcotrumpet »

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


Inviato dal mio iPhone utilizzando Tapatalk
Justintime
Posts: 228
Joined: Thursday 21 May 2015 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Scripts doesn't work in domoticz

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests