title: nodejs for linux server programming / as scripting language
body: <p>I am writing a script for provisioning new users for my application. 
  Script will be written in node, as one of its tasks will be connecting to mysql to create new users in application's database.</p>
  
  <p>I tried to use spawn-sync library (that surprisingly seems to be also async) to execute bash commands but every single one of them I need to do the following:</p>
  
  <pre><code>var spawnSync = require('spawn-sync');
  var user_name = process.argv[2];
  
  new Promise((resolve)=&gt;{
  
      var result = spawnSync('useradd',[user_name]);
      if (result.status !== 0) {
  
          process.stderr.write(result.stderr);
          process.exit(result.status);
  
      } else {
  
          process.stdout.write(result.stdout);
          process.stderr.write(result.stderr);
  
      }
  
      resolve()
  
  }).then(new Promise(function(resolve){
  
      // execute another part of script
      resolve()
  })
  </code></pre>
  
  <p>Is there a better way of doing this? Whenever I try to look something up, all tutorials on the web seem to be talking only about express when it comes to the nodejs context. </p>
  
  <p>Or perhaps you discourage using nodejs to be used as a scripting serverside laguage?</p>