title: Not getting error code when fails copying remote MySQL DB using PHP -> SSH -> MYSQLDUMP
body: <p>I created a script to copy a remote database using mysqldump inside a SSH connection. Then i ported to my PHP script so i can better manage several servers.</p>
  
  <p>My problem is when the copy fails... I get no error code from the command.</p>
  
  <p>This is the command:</p>
  
  <p>ssh -p22 -i mykey.key -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null backup@hostname "mysqldump -hlocalhost -udbuser --databases db" > myfile.sql</p>
  
  <p>It works =)</p>
  
  <p>PHP code with simplified systax:</p>
  
  <pre><code>$comando = 'ssh -i mykey.key backup@hostname "mysqldump --databases db" &gt; myfile.sql';
  $ret_text = exec($comando, $output, $ret);
  // Doesnt matter if command fails or sucess, result is?
  //$ret = empty
  //$output = empty
  //$ret_text = empty
  </code></pre>
  
  <p>I need to know when the copy failed, does anyone know how to get a remote error code?</p>
  
  <p>Thanks</p>