0

I get reference from Manual PHP And Telnet To sisco to get value from my mikrotik. below is from Manual PHP, and if code from Telnet To sisco the value is same like this, but difference code.

<?php
    set_time_limit(0); 
    $host   = '10.23.45.1';
    $port   = '23';
    $user   = 'edp';
    $pass   = '123';
    $socket = fsockopen($host, $port) or die('Could not connect to: '.$host);
    $userdota = "palma";
    if($socket) 
    { 
        sendcmd($user." \r\n",$socket);
        sendcmd($pass."  \r\n",$socket);
        sendcmd("tool bandwidth-test 10.23.35.41 protocol=tcp direction=both user=adminstrator pass=intel \r\n",$socket);
        $line=fgets($socket);
        echo $line;
    }

    function sendcmd($cmd,$socket) // send command function
    {
      fputs($socket, $cmd, strlen($cmd)); 
    }
?>

I want to get value like i using with command prompt like this

            status: running
          duration: 6s
        tx-current: 509.6kbps   tx-10-second-average: 277.9kbps
  tx-total-average: 277.9kbps
        rx-current: 971.2kbps   rx-10-second-average: 566.7kbps
  rx-total-average: 566.7kbps
       random-data: no
         direction: both

But when i run the code, the value $line is

ÿýÿý ÿý#ÿý

Not like what i want, Can you give me solution?

Community
  • 1
  • 1
AKCode
  • 27
  • 8
  • I'm guessing that you're sending commands way too fast - why don't you use the class that Buksy supplied in the [thread you linked to](http://stackoverflow.com/questions/10650037/telnet-to-cisco-switch-using-php)? – h2ooooooo Mar 20 '14 at 08:41
  • @h2ooooooo i had try that's code but the values always like above :'(. – AKCode Mar 20 '14 at 09:09

0 Answers0