View Full Version : using an xbmc script to call unix commands and display them the results ?
schneidz
2009-07-23, 08:09
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:xbmc.executebuiltin("XBMC.RunScript(ls,$HOME)")
is there a way to show the contents returned from ls by using os.system() within xbmc ?
thanks,
althekiller
2009-07-23, 08:12
You want os.popen().
Here a function we did for the Installer Passion-XBMC script in order to list the content of a directory:
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
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:
import os
stdout_handle = os.popen("echo something", "r")
text = stdout_handle.read()
schneidz
2009-07-24, 07:29
^ thanks, i guess what i was looking for was something like a hello world example