title: How to wait for the completion of the wget and tar command?
body: <p>I have a code array similar to the one below.</p>
  
  <pre><code>$ssh-&gt;exec('mkdir /root/example');
  $ssh-&gt;exec('wget -q -P /root http://www.example.com/example.tar.bz2');
  $ssh-&gt;exec('tar -xjf /root/example.tar.bz2 -C /root/example');
  $ssh-&gt;exec('rm /root/example.tar.bz2');
  </code></pre>
  
  <p>My problem;</p>
  
  <p>The next command is starting before the wget and tar commands are completed. How do I wait for the completion of the wget and tar command?</p>
  
  <p><strong>I tried;</strong></p>
  
  <pre><code>$ssh-&gt;exec('mkdir /root/example');
  $ssh-&gt;exec('wget -q -P /root http://www.example.com/example.tar.bz2');
  sleep(10);
  $ssh-&gt;exec('tar -xjf /root/example.tar.bz2 -C /root/example');
  sleep(10);
  $ssh-&gt;exec('rm /root/example.tar.bz2');
  </code></pre>
  
  <p>I tried sleep command. But not work.</p>
  
  <p>Edit: My english is bad.</p>