3

I want to run a command inside of a script tag within my index.html file using node webkit. Is such a thing possible and how would the code look like if I wanted to execute the command 'pwd' for example?

Thanks in advance

asked Jul 30, 2014 at 19:13

2 Answers 2

4

Does something like this not work?

var sys = require('sys')
var exec = require('child_process').exec;
var child;
// executes `pwd`
child = exec("pwd", function (error, stdout, stderr) {
 sys.print('stdout: ' + stdout);
 sys.print('stderr: ' + stderr);
 if (error !== null) {
 console.log('exec error: ' + error);
 }
});
answered Jul 30, 2014 at 19:17
Sign up to request clarification or add additional context in comments.

3 Comments

thanks worked as expected, would this work for executing an entire shell script as well?
It should. As long as you have the path to the script.
It didn't work for me. I tried several commands. I'm always getting: Error: spawn ENOENT
4

The documentation for node webkit states:

Complete support for Node.js APIs and all its third party modules.

Which would indicate that you could use the node childprocess api:

http://nodejs.org/api/child_process.html

answered Jul 30, 2014 at 19:41

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.