1

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 Answers1

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

child.stdout.pipe(process.stdout)
Maksim Morozov
  • 53
  • 4
  • 13
  • Thanks for the response. I think that will help me redirect the child output to a stdout, but as far as I know there is no active stdout for the parent process (which is why I'm looking to create a new cmd.exe for the output). My biggest problem might be that the cmd.exe window doesn't actually show up. Even if I try to spawn an instance of cmd.exe explicitly. – user2762094 Sep 10 '13 at 19:00
  • @user2762094 what do you mean by "active stdout" ? – Maksim Morozov Sep 10 '13 at 19:12
  • As I said, I am new to jsnode so sorry if my terminology is confusing. I was reading this solution yesterday (http://stackoverflow.com/questions/1528152/is-it-possible-to-build-a-console-app-that-does-not-display-a-console-window-whe), specifically, EDIT 2 in that link. When I launch my parent executable from the command line it returns immediately so if the above link is correct I believe the stdin/stdout are set to NULL in the parent. – user2762094 Sep 10 '13 at 19:46