title: Spawning a child process with tty in node.js
body: <p>I am trying to do some work on a remote server using ssh--and ssh is called on the local machine from node.js</p>
  
  <p>A stripped down version of the script looks like this:</p>
  
  <pre><code>var execSync = require("child_process").execSync;
  var command =
    'ssh -qt user@remote.machine -- "sudo mv ./this.thing /to/here/;"';
  execSync(command,callback);
  
  function callback(error,stdout,stderr) {
  
    if (error) {
      console.log(stderr);
      throw new Error(error,error.stack);
    }
    console.log(stdout);
  }
  </code></pre>
  
  <p>I get the <code>requiretty</code> error <code>sudo: sorry, you must have a tty to run sudo</code>.</p>
  
  <p>If I run <code>ssh -qt user@remote.machine -- "sudo mv ./this.thing /to/here/;"</code> directly from the command line--in other words, directly from a tty--I get no error, and <code>this.thing</code> moves <code>/to/there/</code> just fine.</p>
  
  <p>This is part of a deploy script where it really wouldn't be ideal to add <code>!requiretty</code> to the sudoers file.</p>
  
  <p>Is there anyway to get node.js to run a command in a tty?</p>