I need to build a javascript engine (duktape or jerryscript) for a embedded device which should be capable of executing shell commands. how can this be achieved?
how to execute shell commands from duktape
383 Views Asked by Ram At
1
There are 1 best solutions below
Related Questions in EMBEDDED
- MSP430F5529 on the MSPEXP430F5529LP: UART is not actually transmitting despite seemingly correct setup. What is wrong?
- A FPGA Project Proposal where I can use both PS and PL
- Program doesn't run after DFU
- Sending struct through queue
- How to generate a VPI warpmap for polynomial distortion correction?
- How to present this example concept in UML: Using 2 LCD displays in C/C++
- CLion: Debug via St-Link
- Portenta H7 Baremetal Development and a Little Guidance on Embedded System Learning Roadmap
- STM32 RTC3 Mixed Mode: Writing TR resets SSR
- Unable to read value from gpio set as input
- Mbed TLS: in-place en-/decryption for OAEP doesn't seem to work
- Shared variable read from low priority thread in preemptive scheduling
- Own Pattern / framework for interfacing with components in C
- Performance Difference Between Global Variable and Local Variable in Embedded Systems
- Comparing analog signal from Electret mic with samples
Related Questions in IOT
- thingsboard: reformat shared attribute JSON before publishing via MQTT
- Not able to recieve message sent from mobile to GSM SIM900 but other functionalities working
- Python: Cannot Run Linux Terminal Commands With Scripts
- How to run Zephyr Echo Client-Server sample using nrf52840dk & nrf52840dongle?
- Communication between the Neo6m GPS and the Esp32
- Turn phone with an IR blaster into wifi enabled IR hub
- Unable to start the Coap server in a Spring boot application
- How to create a photo gallery widget/database?
- AWS IoT Self-managed certificate signing with CreateCertificateFromCsr API
- Azure IOT central command/NodeRed
- PyFirmata servo control issue (Arduino with Python)
- How to connect bluetooth devices using flutter blue plus?
- Does CdiCenteroutput support in lipari-mid & kiska - mid (55ppm)
- "Blynk Connection Issue with Arduino and ESP8266 in IoT Project"
- How to control Tuya API device with an HTML request
Related Questions in DUKTAPE
- How to wrap C++ classes with Duktape
- Build Duktape for specific platform (ARM 32/ ARM 64)
- How to get the class name when running a constructor function in duktape?
- Android Duktape NullPointerException while Internet is not there
- Catching and recovering from error in C++ function called from Duktape
- Can Duktape make http requests
- Use promise on Duktape
- Postgres equivalient in SQLite to search JSON object
- Define JavaScript static method in C using Duktape
- Azure login using Javascript in zabbix server. its using duktape javascript implementation
- How can I do some clean up jobs when an object is being deleted / disposed in duktape?
- Construct variadic template argument list
- Add auto-complete with non-standard builtins w/Visual Studio Code/JS
- Timeout stopped working for me with Duktape v2.7.0
- how to execute shell commands from duktape
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
With duktape in C, you can easily create a native ECMAScript function and create a reference to it via the global object:
#include "duktape.h" int main() { /* create heap */ duk_context* heap = duk_create_heap(NULL,NULL,NULL,NULL, NULL); /* preferably, set an error callback here */ /* push the native function on the stack */ duk_push_c_function(ctx, /* heap context */ &native_js_shell, /* native function pointer */ 1); /* accepted arguments */ /* make this javascript function a property of the global object */ duk_put_global_string(ctx, /* heap context*/ "shell"); /* function name in js */ return 0; } /* Your native C function */ duk_ret_t native_js_shell(duk_context* ctx) { /* obtain the argument from javascript */ const char* cmd = duk_safe_to_string(ctx, /* heap context */ -1); /* position on stack */ /* run the shell command, etc. */ /* ... */ }All the explanation for the
duk_*functions can be found in the duktape API, but perhaps this gives you an idea of how it's structured.p.s. Welcome to Stack Overflow! Your question may have been downrated since it pretty much requires someone to write all the code for you. In general, in the future, try to do the research on your own, and ask specific questions as you get stuck. :)