Hello World
- Enable Termux

ExtExec allows you to execute Linux shell commands in the powerful Linux environment provided by the free app called Termux.

app.ExtExec( name, file, args, options )

Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.

The Termux app runs as a service and there's almost no limit to what you can achieve with a full blown Linux machine running on your Android device!

How about installing git, or nodejs or using ssh or gzip.
Try typing 'busybox' at the terminal prompt to see what built-in commands are already available to you.

Enable Termux

To enable termux support you have to install Termux and the Tasker Plugin from PlayStore first.

Then give termux sdcard permissions in the Android settings under apps/termux.

After that create a symbolic link from the tasker plugin folder to your home directory:

mkdir -p .termux /sdcard/termux/scripts
ln -s /sdcard/termux/scripts .termux/tasker

Finally you can run a termux shell script from inside DroidScript:

Example - Open Termux and pass arguments

function OnStart()
    app.WriteFile( "/sdcard/termux/scripts/", "echo Hello $1 and $2" );
    var err = app.ExtExec( "termux", "", 'World "' + app.GetUser() + '"', "" );
    if( err ) app.Alert( "Termux Error:" + err );
    Copy     Copy All       Run      

Example - Execute in Background and retreive output

var itv, lock = "/sdcard/.termuxlock";
var script = `
{ # this is a comment
    echo This is a message # prints to stdout
    sleep 1 # waits 1 second
    echo This is an error 1>&2 # prints to stderr
} 1>/sdcard/out.txt 2>/sdcard/err.txt; # forward stdout and stderr to files
+ lock; // remove script lock file

function OnStart()
    app.WriteFile( "/sdcard/termux/scripts/", script );
    app.WriteFile( lock, "" );

    app.ShowProgress( "Script is running" );
    var err = app.ExtExec( "termux", "", "", "hide" );
    if(err) app.Alert(err);

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

    txt = app.CreateText( "", .8, .8, "monospace,multiline,left" );
    lay.AddChild( txt );

    app.AddLayout( lay );

    itv = setInterval( CheckReady, 100 );

function CheckReady()
    if( !app.FileExists( lock ))

        var stdout = app.ReadFile( "/sdcard/out.txt" );
        var stderr = app.ReadFile( "/sdcard/err.txt" );

        var text =
            "stdout:\n" + stdout + "\n\n" +
            "stderr:\n" + stderr;

        txt.SetText( text );
    Copy     Copy All       Run      
string: path to file or folder ( “/absolute/...” or “relative/...” )
string: “termux”
string: comma “,” separated: “hide”