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
user2554585
3,7197 gold badges22 silver badges23 bronze badges
2 Answers 2
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
tier1
6,4736 gold badges47 silver badges76 bronze badges
Sign up to request clarification or add additional context in comments.
3 Comments
user2554585
thanks worked as expected, would this work for executing an entire shell script as well?
tier1
It should. As long as you have the path to the script.
lima_fil
It didn't work for me. I tried several commands. I'm always getting:
Error: spawn ENOENTThe 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:
answered Jul 30, 2014 at 19:41
j03m
5,3314 gold badges48 silver badges50 bronze badges
Comments
lang-js