Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Invoke shell commands from a Scripting environment?

  • I received a question over the phone of if it were possible to invoke shell commands in an easy synchronous manner from a scripting environment. To that, I have this answer:

    Yes, it is very easy to get synchronous shell calling in a Mango JavaScript context. While we haven't added the ability to toggle this only on a per-script basis, you can have a script in Mango/bin/ext-enabled like


    if "%1" == "init" (
            rem Set the -scripting flag for shell extensions in JavaScript environments
            set JAVAOPTS=%JAVAOPTS% -Dnashorn.args=-scripting

    case "$1" in
            # Set the -scripting flag for shell extensions in JavaScript environments
            JAVAOPTS="$JAVAOPTS -Dnashorn.args=-scripting"

    Important to remember "init" is called on a stop, then start, but not on a restart (which calls the scripts with "restart")

    Which will give us the $EXEC option an the option to use backtick syntax, as well as several other utilities, expanded upon here: or perhaps:

    What this will enable us to do in a Mango script is:

    //Linux only, Windows may have PATH issues.
    print(`echo "Wow that's awesome!"`);
    print($EXEC('echo "Alternative syntax?!?"'));

    It would also be possible for someone to invoke command line functions without toggling on the -scripting nashorn mode, using

    //Asynchronously kick off the command"command", timeout);
    //Synchronously kick off the command, get an object with the command and output back
    var response ="command", timeout);
    print( response.key );
    print( response.value );