javascript - Launching an exe from node.js, and send data between them -


ok, i'm creating webpage using socket.io in node.js. works great, , data going each device should. want expand, , use node.js control pc.

i've read this: child process , gotten code wich runs executable, , prints output in console.

var spawn = require('child_process').spawn;  var ahk = spawn('outsidenode.exe'); ahk.stdout.on('data', function(data){     console.log(data.tostring()); }); 

here code, or script outsidenode.exe gets launched. i'm using autohotkey this.

loop,10 {     fileappend,external program spawned node.js says hi!,*     sleep,1000 } exitapp 

this works 1 way. node.js captures ahk's output. now, problem i'm having is, how send data node.js? , how recieve in ahk? belive need read stdio. i'm new std's.

my current solution using node.js write .txt file disk command want give, , seperate .exe file reads .txt , executes command , exits. works, slow-ish, , feels wrong way.
also, want asynchronous, or synchronous? 1 can other stuff node.js while executable thing. have wait sure file can overwritten.

any input on how appreciated.

there option pass arguments spawned app. maybe that's looking for. how handle arguments in exe question related other programming languages. in node, child processes run asynchronous , non-blocking, that's 1 looking for. however, if want communicate between programs, can write stdin of childprocess so:

child.stdin.write("here go"); 

your exe must able wait stdin in order process incoming data.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -