title: ruby system command check exit code
body: <p>I have a bunch of system calls in ruby such as the following and I want to check their exit codes simultaneously so that my script exits out if that command fails.</p>
  
  <pre><code>system("VBoxManage createvm --name test1")
  system("ruby test.rb")
  </code></pre>
  
  <p>I want something like</p>
  
  <p><code>system("VBoxManage createvm --name test1", 0)</code> &lt;-- where the second parameter checks the exit code and confirms that that system call was successful, and if not, it'll raise an error or do something of that sort.</p>
  
  <p>Is that possible at all?</p>
  
  <p>I've tried something along the lines of this and that didn't work either.</p>
  
  <pre><code>system("ruby test.rb")
  system("echo $?")
  </code></pre>
  
  <p>or </p>
  
  <pre><code>`ruby test.rb`
  exit_code = `echo $?`
  if exit_code != 0
    raise 'Exit code is not zero'
  end
  </code></pre>