Back

SysExec

JS Py
Hello World

Executes a shell command on the android shell.

app.SysExec( command, options='', maxRead?, timeout? ) → String

NOTE: You have to add a 'exit' command at the end of your script because the shell does not terminate automatically after finishing.

See Also: ExtExec

Example - ListDir SH

function OnStart()
{
    var delim = "\0";
    var list = app.SysExec( 'ls -ap /sdcard/;exit', "sh,log" );
    list = list.split( "\n" ).join( delim );


    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

    lst = app.CreateList( list, 1, 1, "", delim );
    lay.AddChild( lst );

    app.AddLayout( lay );
}
from native import app

def OnStart():
    delim = "\0"
    list = app.SysExec('ls -ap /sdcard/;exit', "sh,log")
    list = list.split("\n").join(delim)

    lay = app.CreateLayout("linear", "VCenter,FillXY")

    lst = app.CreateList(list, 1, 1, "", delim)
    lay.AddChild(lst)

    app.AddLayout(lay)
    Copy     Copy All       Run      
Number
String
Number: seconds
String: log, noread, “sh” or “su”