How to create a telnet session using php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • summer law
    New Member
    • Mar 2012
    • 4

    How to create a telnet session using php?

    Anyone can help me to do the following?
    Im new to php as i had did it using python but i not sure how to write it in php as it does not have any telnet module.

    Write a PHP code using proc_open()

    the commands are
    1. telnet 10.247.5.3
    2. when login prompt, type xxx
    3. when password prompt, type zzz.
    4. run the command sh run.

    thanks!
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Checkout php.net/fsockopen.

    Dan

    Comment

    • summer law
      New Member
      • Mar 2012
      • 4

      #3
      Thanks Dan,

      i had tried the following codes -->

      Code:
      <?php
      $ip = '192.168.x.x';
      $port = '23';
      $connect = fsockopen($ip,$port);
      
      if(!$connect){
          echo 'fail';
      }
      else{
          echo 'pass';
      }
      ?>
      But how can i input the username and password ?
      i had tried fwrite($connect , 'username'); but i dont seem to be working.

      Comment

      Working...