title: Nodejs : Return stdout
body: <p>I am trying to return username using this simple function , but its not working .I thing its  asynchronous thats why it returns <code>undefined</code> . So what is the best way to return value from <code>stdout</code> ?</p>
  
  <pre><code>function User() {
      exec('whoami',function (error, stdout, stderr) {
              return stdout;
          });
  }
  </code></pre>
  
  <p>There is a node module <a href="https://github.com/mgutz/execSync" rel="nofollow">execSync</a> , but its not for production machine .</p>