title: Is read() necessary before write() with SSH via PHPSecLib?
body: <p>I have written a small script that issues a series of commands via <code>write()</code> to a linux machine, with a 5 second <code>sleep()</code> between each one. The exact same commands work when entered manually but despite being connected successfully, do not seem to work when used from a PHP script.</p>
  
  <p>As this is the case, I am curious if using <code>read()</code> is absolutely necessary prior to issuing a <code>write()</code> command?</p>
  
  <pre><code>&lt;?php
  
  include('Net/SSH2.php');
  
      $serverhostname = "IP_HERE";
      $ssh_username = "root";
      $ssh_password = "PASS_HERE";
  
      // Establish new SSH2 Connection
      $connection = new Net_SSH2($serverhostname, 22);
  
      if($connection-&gt;login($ssh_username, $ssh_password))
      {
          echo "LOGGED IN! &lt;/br&gt;";
  
          sleep(5);
  
          $result = $connection-&gt;write('en PASS_HERE\r\n');
          echo "RESULT: " . $result . " &lt;/br&gt;";
  
          sleep(5);
  
          $result = $connection-&gt;write('configure terminal\r\n');
          echo "RESULT: " . $result . " &lt;/br&gt;";
  
          sleep(5);
  
          $result = $connection-&gt;write('interface ve 110\r\n');
          echo "RESULT: " . $result . " &lt;/br&gt;";
  
          sleep(5);
  
          $result = $connection-&gt;write('port-name Test_Brett\r\n');
          echo "RESULT: " . $result . " &lt;/br&gt;";
      }
      else
      {
          echo "SSH Connection Failed. Check that the remote host is online and accepting connections!";
      }
  
  ?&gt;
  </code></pre>
  
  <p><em>UPDATE</em></p>
  
  <pre><code>$result = $connection-&gt;write('en PASS_HERE\n');
  $result = $connection-&gt;write('configure terminal\n');
  $result = $connection-&gt;write('interface ve 110\n');
  $result = $connection-&gt;write('port-name Test_Brett\n');
  $connection-&gt;setTimeout(5);
  echo $connection-&gt;read();
  </code></pre>