How can I redirect a jsnode child process output to a cmd prompt?

1.2k Views Asked by At

I have an appjs application that is built to be a GUI which allows the user to run whole bunch of other .exe applications. These other .exe applications are created on a mouse click by the 'spawn()' command. Some of the .exe programs require output on the command line, however the main application doesn't use a command prompt.

So basically, I want my child processes to pipe their stdout into a command prompt window. The command prompt window is not running before hand. I am new to jsnode and I am having trouble getting this to work.

Here is the code. The name of the application is getting passed into the function and I am constructing the string and then spawning the process.

var appName = this.getAttribute('app');    
processStr = './' + appName + '.exe';    
var spawn = require('child_process').spawn;    
cmd  = spawn(processStr, [], { cwd: './', env: process.env} );

Note, even if I change it to below I cannot get the command prompt window to show up.

 cmd  = spawn('c:/windows/system32/cmd.exe', [], { cwd: './', env: process.env} );
1

There are 1 best solutions below

3
On
var spawn = require('child_process').spawn;
var child = spawn('echo',  ['Hello world!']);

child.stdout.pipe(process.stdout)