Kodi Community Forum
how can I run a command line via a button? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: how can I run a command line via a button? (/showthread.php?tid=223994)



how can I run a command line via a button? - qwertyjjj - 2015-04-10

I have 2 command lines that I use to start a vpn.
In the terminal these are:
sudo openvpn --config /etc/openvpn/filename.ovpn
sudo openvpn stop

How can I add these as a shortcut so that I can just click on them within xbmc?


RE: how can I run a command line via a button? - pjmavadiya - 2015-04-13

1. Create one shell script which is Linux executable script.
2. Put bot the command inside that script.
3. Use RunScript(<script name>).
4. Put RunScript code in button onclick event.

Thanks
Prashant


RE: how can I run a command line via a button? - qwertyjjj - 2015-04-14

(2015-04-13, 12:26)pjmavadiya Wrote: 1. Create one shell script which is Linux executable script.
2. Put bot the command inside that script.
3. Use RunScript(<script name>).
4. Put RunScript code in button onclick event.

Thanks
Prashant

How do I get the button on screen within xbmc?
ie so I can move into say Programs-->Add ons and just click to start to script?


RE: how can I run a command line via a button? - pjmavadiya - 2015-04-14

Download this zip file:
Open default.py and write commands to execute when you click on program addon.
(this addon will be listed under program addon section)

<< https://www.dropbox.com/s/oe5f8f8fkbljy1p/plugin.program.command.zip?dl=0 >>


RE: how can I run a command line via a button? - deepeeme - 2020-02-25

I know this is an old thread but the solution is exactly what I was looking for.
Unfortunately I can't get get it to work in Kodi 18.5 on Raspbian Buster, using your addon and modifying it with your instructions
Anything I can change to get it to work?

Thanks


RE: how can I run a command line via a button? - Takezo36 - 2020-04-03

(2020-02-25, 06:56)deepeeme Wrote: I know this is an old thread but the solution is exactly what I was looking for.
Unfortunately I can't get get it to work in Kodi 18.5 on Raspbian Buster, using your addon and modifying it with your instructions
Anything I can change to get it to work?

Thanks

Hi,

last time i tried to use it RunScript didn't work for me (given that's like a year ago). I ended up using subprocess.popen
Feel free to copy paste what you need from here 
https://github.com/Takezo36/applauncherkodi/blob/master/plugin.program.applauncher/resources/lib/AppRunner.py

If you just want to have a link to some program in kodi you can checkout my applauncher plugin
https://github.com/Takezo36/repo/blob/master/repository.takezo36/repository.takezo36-1.0.0.zip?raw=true
just deactivate the os listing and add a new custom entry.

Edit:
Wooops small correction i didn't have a problem with runscript but with system.exec. any ways runscript is the wrong thing in the first place. AFAIK it's meant for running python scripts not shell scripts. For shell scripts go for subprocess.popen


RE: how can I run a command line via a button? - deepeeme - 2020-04-10

(2020-04-03, 17:24)Takezo36 Wrote:
(2020-02-25, 06:56)deepeeme Wrote: I know this is an old thread but the solution is exactly what I was looking for.
Unfortunately I can't get get it to work in Kodi 18.5 on Raspbian Buster, using your addon and modifying it with your instructions
Anything I can change to get it to work?

Thanks

Hi,

last time i tried to use it RunScript didn't work for me (given that's like a year ago). I ended up using subprocess.popen
Feel free to copy paste what you need from here 
https://github.com/Takezo36/applauncherkodi/blob/master/plugin.program.applauncher/resources/lib/AppRunner.py

If you just want to have a link to some program in kodi you can checkout my applauncher plugin
https://github.com/Takezo36/repo/blob/master/repository.takezo36/repository.takezo36-1.0.0.zip?raw=true
just deactivate the os listing and add a new custom entry.

Edit:
Wooops small correction i didn't have a problem with runscript but with system.exec. any ways runscript is the wrong thing in the first place. AFAIK it's meant for running python scripts not shell scripts. For shell scripts go for subprocess.popen 
Thanks very much for that Takezo36....I'll give it a try.