user2554585
user2554585

Reputation: 3669

Execute Command from Node Webkit

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

Upvotes: 3

Views: 2292

Answers (2)

j03m
j03m

Reputation: 5303

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

Upvotes: 4

tier1
tier1

Reputation: 6433

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);
  }
});

Upvotes: 4

Related Questions