using an xbmc script to call unix commands and display them the results ?
#1
hi, is it possible to run commands from within xbmc using a script.

would i be able to list the contents returned from ls by using this code:
Code:
xbmc.executebuiltin("XBMC.RunScript(ls,$HOME)")

is there a way to show the contents returned from ls by using os.system() within xbmc ?

thanks,
Reply
#2
You want os.popen().
Reply
#3
Smile 
Here a function we did for the Installer Passion-XBMC script in order to list the content of a directory:

Code:
import os
def listDirFiles( path):
   """
   List the files of a directory
   @param path:
   """
   print "listDirFiles: content of directory: %s"%path
   dirList = os.listdir( str( path ) )

   return dirList

This will work on every OS including linux
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#4
As althekiller said, if you want to get the STDOUT from the execution of external commands. Rather than use os.system(), use os.popen(), like so:
Code:
import os
stdout_handle = os.popen("echo something", "r")
text = stdout_handle.read()
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#5
^ thanks, i guess what i was looking for was something like a hello world example
Reply

Logout Mark Read Team Forum Stats Members Help
using an xbmc script to call unix commands and display them the results ?0