admin管理员组

文章数量:1410689

I want to run a mand 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 mand 'pwd' for example?

Thanks in advance

I want to run a mand 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 mand 'pwd' for example?

Thanks in advance

Share Improve this question asked Jul 30, 2014 at 19:13 user2554585user2554585 3,6797 gold badges21 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 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);
  }
});

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/api/child_process.html

本文标签: javascriptExecute Command from Node WebkitStack Overflow