title: How can I get the returned value from the child_process.exec in javascript?
body: <p>I tried the following code, it shows the res is undefined.
  How can I return the stdout?</p>
  
  <pre><code>function run_shell_command(command)
  {
      var res
      exec(command, function(err,stdout,stderr){
       if(err) {
          console.log('shell error:'+stderr);
      } else {
          console.log('shell successful');
      }
      res = stdout
      // console.log(stdout)
      });
      return res
  } 
  </code></pre>