title: Node child process, not getting the output from CLI
body: <p>I am trying to run a basic cmd command with a child process, i am testing some cli's with nodejs and can't understand why i am not getting any output, here is a simple example:</p>
  
  <pre><code>const spawn = require('child_process').spawn
  let child = spawn('cmd.exe',['/K'])
  child.stdout.setEncoding('utf8');
  child.stdout.on('data', (data) =&gt; {
      console.log(data.toString())
  });
  
  child.stdin.write('heroku login\n');
  </code></pre>
  
  <p>The output should be :</p>
  
  <pre><code>heroku: 
  
  Enter your login credentials
  
  Email :
  </code></pre>
  
  <p>what am i missing? Thx</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I have been playing with the code and could get what i want:</p>
  
  <pre><code>const spawn = require('child_process').spawn
  let child = spawn('heroku',['login' ,'-i']);
  
  child.stderr.on('data', function(data) {        
      child.stdin.write('email@hotmail.com');
  });
  </code></pre>
  
  <p>Once the stderr.on fired i have to enter the email address
  but after i call <code>child.stdin.write('email@hotmail.com');</code> i am getting an error:</p>
  
  <pre><code>'sh' is not recognized as an internal or external command,
  operable program or batch file.
  </code></pre>
  
  <p>Can anyone let me know what might be the cause of this error?</p>