title: node.js execute multiple commands with sudo
body: <p>In my node.js script, I need to run these two commands with sudo:</p>
  
  <pre><code>execSync('sudo rsync -a ' + dir1 + " " + dir2);
  execSync('sudo rm -Rf ' + dir1);
  </code></pre>
  
  <p>but this cause that it will ask for sudo password two times;
  other than this, if I digit a wrong password, the script goes on without requesting it again;
  how can I cache the password to avoid to be prompted for it two times and wait until the correct password is supplied before going on?</p>