title: phpseclib with ssh2 and telnet command on the router
body: <p>I'm trying to access a Cisco router within a network but I'm not getting it using phpseclib library</p>
  
  <pre><code>$login = "guest";
  $pw = "123456";
  $ssh = new Net_SSH2("11.222.333.44");
  if(!$ssh-&gt;login($login, $pw)){ exit("FAILED !!!!")}
  //That I am connected to the network
  
  $ssh-&gt;exec("telnet 555.66.77.8");
  //Now I need to connect to the telnet router using the same network login and password
  
  echo $ssh-&gt;exec("$login");
  $ssh-&gt;exec('cd /');
  echo $ssh-&gt;exec("$pw");
  
  echo $ssh-&gt;getLog();
  </code></pre>
  
  <p>already tried:</p>
  
  <pre><code>echo $ssh-&gt;exec("$login");
  $ssh-&gt;exec('cd /');
  echo $ssh-&gt;exec("$pw");
  </code></pre>
  
  <hr>
  
  <pre><code>echo $ssh-&gt;exec("$login");
  $ssh-&gt;exec('\n');
  echo $ssh-&gt;exec("$pw");
  </code></pre>
  
  <hr>
  
  <pre><code>$ssh-&gt;read(Username:');
  echo $ssh-&gt;write($login.'\r');
  $ssh-&gt;read('Password:');
  echo $ssh-&gt;write($pw.'\r');
  </code></pre>
  
  <p>I'm not succeeding and would like help, follow the log:</p>
  
  <pre><code>   &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0936, network: 0.0936s)
  00000000  00:00:00:00:00:00:00:0c:0d:0a:55:73:65:72:6e:61  ..........Userna
  00000010  6d:65:3a:20                                      me: 
  
  &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 30.6541, network: 30.6541s)
  00000000  00:00:00:00:00:00:00:1f:0d:0a:25:20:55:73:65:72  ..........% User
  00000010  6e:61:6d:65:3a:20:20:74:69:6d:65:6f:75:74:20:65  name:  timeout e
  00000020  78:70:69:72:65:64:21                             xpired!
  
  &lt;- NET_SSH2_MSG_CHANNEL_REQUEST (since last: 2.0904, network: 2.0904s)
  00000000  00:00:00:00:00:00:00:0b:65:78:69:74:2d:73:74:61  ........exit-sta
  00000010  74:75:73:00:00:00:00:01                          tus.....
  
  -&gt; NET_SSH2_MSG_CHANNEL_EOF (since last: 0, network: 0s)
  00000000  00:00:00:00                                      ....
  
  -&gt; NET_SSH2_MSG_CHANNEL_CLOSE (since last: 0, network: 0s)
  00000000  00:00:00:00                                      ....
  
  &lt;- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (since last: 0, network: 0s)
  00000000  00:00:00:00:00:00:00:01:00:00:00:24:43:6f:6e:6e  ...........$Conn
  00000010  65:63:74:69:6f:6e:20:63:6c:6f:73:65:64:20:62:79  ection closed by
  00000020  20:66:6f:72:65:69:67:6e:20:68:6f:73:74:2e:0d:0a   foreign host...
  
  &lt;- NET_SSH2_MSG_CHANNEL_EOF (since last: 0, network: 0s)
  00000000  00:00:00:00                                      ....
  
  &lt;- NET_SSH2_MSG_CHANNEL_CLOSE (since last: 0, network: 0s)
  00000000  00:00:00:00                                      ....
  
  -&gt; NET_SSH2_MSG_CHANNEL_OPEN (since last: 0, network: 0s)
  00000000  00:00:00:07:73:65:73:73:69:6f:6e:00:00:00:01:7f  ....session.....
  00000010  ff:ff:ff:00:00:40:00                             .....@.
  
  &lt;- NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION (since last: 0.0624, network: 0.0624s)
  00000000  00:00:00:01:00:00:00:01:00:00:00:00:00:00:80:00  ................
  
  -&gt; NET_SSH2_MSG_CHANNEL_REQUEST (since last: 0, network: 0s)
  00000000  00:00:00:01:00:00:00:07:70:74:79:2d:72:65:71:01  ........pty-req.
  00000010  00:00:00:05:76:74:31:30:30:00:00:00:50:00:00:00  ....vt100...P...
  00000020  18:00:00:00:00:00:00:00:00:00:00:00:01:00        ..............
  
  &lt;- NET_SSH2_MSG_CHANNEL_SUCCESS (since last: 0.0156, network: 0.0156s)
  00000000  00:00:00:01                                      ....
  
  -&gt; NET_SSH2_MSG_CHANNEL_REQUEST (since last: 0, network: 0s)
  00000000  00:00:00:01:00:00:00:05:73:68:65:6c:6c:01        ........shell.
  
  &lt;- NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST (since last: 0.0156, network: 0.0156s)
  00000000  00:00:00:01:00:20:00:00                          ..... ..
  
  &lt;- NET_SSH2_MSG_CHANNEL_SUCCESS (since last: 0, network: 0s)
  00000000  00:00:00:01                                      ....
  
  -&gt; NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
  00000000  00:00:00:01:00:00:00:09:6f:69:33:33:34:34:30:36  ........bss1991
  00000010  0a                                               .
  </code></pre>