Search code examples
javascriptduktape

Does Duktape has a Function for Executing an External Program in Linux?


I am using Duktape on Linux (Command Line, not Browser),
and would like my code to execute an external program in Linux, for example ls.

I went over Duktape's website, looking for Reference of the JavaScript functions supported by this Interpreter and Compiler,
but couldn't find any.

I did find there an API Reference, but that seems to be talking about calling functions that the Interpreter/Compiler library provides to outside callers,
and not the functions that are used inside a JavaScript program, that the Interpreter/Compiler runs..

Does any one know If there is a way to Execute an external program in Duktape in Linux,
and If yes, a 1-2 line sample code would be really helpful.

Thank you


Solution

  • Duktape is a pure JS execution environment. It does only provide functionality as defined in specific JS versions (mostly ES5, some ES6 and very few ES7). See also the Post ES5 status page.

    Accessing the file system or starting processes is not part of the JS language defintion. For that you have to provide your own environment, which implements such functionality for scripts.