Kodi Community Forum

Full Version: System.Exec() with argument?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm running a simple bash script from a menu item using System.Exec(/path/to/script.sh), which works great. However if I try to pass an argument with System.Exec(/path/to/script.sh --argument) Kodi crashes and the bash script doesn't seem to run. Is it not possible to pass an argument when using System.Exec? Thanks!
I can confirm this problem.

My recommendation, use RunScript and write a python script which executes the shell commands by using the os-module: import os. As RunScript is able to take arguments which can be accessed by sys.argv. So you can pass them to the shell script in that way.
(2019-08-17, 07:54)DaVu Wrote: [ -> ]I can confirm this problem.

My recommendation, use RunScript and write a python script which executes the shell commands by using the os-module: import os. As RunScript is able to take arguments which can be accessed by sys.argv. So you can pass them to the shell script in that way.

Works perfectly! Thanks for the tip. Much appreciated.
yw
Could potentially try the following patch.

Currently the only thing passed through is the first argument, everything else is dropped. I've only got a mac os machine, so not runtime tested

Edit: removed patch as it was wrong. No need to keep that online. SeeĀ https://github.com/xbmc/xbmc/pull/16526 for working PR
If you can build from source, you can try the following commit.

https://github.com/fuzzard/xbmc/commit/d...9df70c95d4

Was able to test on a vm using instructions provided by Davu on how to reproduce what you were trying to do (Mac user here).
To use it, use a , as a separator between arguments. An example is below. The test.sh script was just a script that started gnome-terminal and any arguments passed

cpp:

parallels@parallels-Parallels-Virtual-Platform:~/kodi$ kodi-send -a "System.Exec(/home/parallels/test.sh,"--hide-menubar")"
Sending: {'content': 'System.Exec(/home/parallels/test.sh,--hide-menubar)', 'type': 'action'}
parallels@parallels-Parallels-Virtual-Platform:~/kodi$ kodi-send -a "System.Exec(/home/parallels/test.sh,'--hide-menubar')"
Sending: {'content': "System.Exec(/home/parallels/test.sh,'--hide-menubar')", 'type': 'action'}
parallels@parallels-Parallels-Virtual-Platform:~/kodi$ kodi-send -a "System.Exec(/home/parallels/test.sh)"
Sending: {'content': 'System.Exec(/home/parallels/test.sh)', 'type': 'action'}
parallels@parallels-Parallels-Virtual-Platform:~/kodi$

I believe Davu has done some testing on this, and it seems to work, but let me know if there are any issues that come up out of actual real world usage.
Yes, I can confirm it working. Tried with a testscript where I either open a terminal/console on Ubuntu or, if a specific parameter (in that case --hide-menubar was given, open the same terminal without a menubar being visible.
Is it going to be merged?