Kodi Community Forum

Full Version: Execute shell command from addon
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If I SSH into Libreelec on my rPi I can run
Code:
systemctl stop service.downloadmanager.transmission.service

How can I replicate this action using my addon?
http://kodi.wiki/view/list_of_built-in_functions

System.Exec

There are a few other ways as well.
I tried:

Code:
import xbmc
xbmc.executebuiltin('System.Exec(systemctl stop service.downloadmanager.transmission.service)')

but nothing happens. Actually it seems to crash;

Quote:12:31:39 620.833069 T:1962889216 ERROR: ActiveAE::Resume - failed to init
12:31:39 620.833679 T:1962889216 FATAL: OnApplicationMessage: Failed to restart AudioEngine after return from external player
some other options are:
- os.system()
- subprocess.call()
Just out of curiosity, when kodi executes a shell script does it use the same user ID as one would use to ssh or does it have it's own specific userid?
Code:
import os
os.system("stop service.downloadmanager.transmission.service")

Code:
import subprocess
subprocess.call('stop service.downloadmanager.transmission.service', shell=True)

These don't seem to be doing anything either...although I'm not getting a crash this time.
that's a different command then in your first post ;-)
Doh, sometimes I do not know why I make these stupid mistakes, it's working now, thanks ronie!