Is there a way to run linux commands from javascript that uses a standalone interpreter (something similar with SpiderMonkey, JavaScript shell)?
We're not sure what makes JavaScript less "real" to some, but thanks to today's web browsers, JavaScript has become a very powerful language. Powerful enough to run Linux in your web browser. French developer Fabrice Bellard has built a JavaScript-based x86 PC emulator capable of running Linux inside a web browser.
In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it. More modern browsers use a technology known as Just-In-Time (JIT) compilation, which compiles JavaScript to executable bytecode just as it is about to run.
Since JavaScript is an interpreted language, you need an interpreter. For the interpreter to run, you need some other language. Linux doesn't come with one built-in (like it does for shell scripts or similar). If you need scripting, use Bash or (for more complex scripts) Python.
The extension to Vim, considered by many as the best Unix text editor ever, Neovim comes with enough powerful features to be your next Javascript Editor for Linux.
A JavaScript interpreter written in PHP 5, that allows to run untrusted scripts in a sandbox on your server. It aims to implement most of Ecma-262 3d edition.
jslibs is a standalone JavaScript interpreter that runs on Linux32/64 and Windows. You can easily run linux commands through the libraries provided by jslibs. It's possible to define JS functions that will call your C/C++ functions that could use system() call, executing some linux commands.
You could use NodeJS. It has a child_process module that can run arbitrary commands. E.G. child_process.spawn()
When your script is finished you run it like this:
node myscript.js
jslibs is a standalone JavaScript interpreter that runs on Linux32/64 and Windows.
You can easily run linux commands through the libraries provided by jslibs.
It's possible to define JS functions that will call your C/C++ functions that could use system()
call, executing some linux commands.
Spider Monkey's way: https://developer.mozilla.org/en/JavaScript_C_Engine_Embedder's_Guide#Native_functions
Google V8 is also an option: http://code.google.com/apis/v8/embed.html#accesssors
So you would have
system('rpm -i myapp.rpm');
system('rpm -i myapp2.rpm');
or perhaps
install('myapp.rpm');
install('myapp2.rpm');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With