我从Manual PHP And Telnet To sisco获得参考,以从我的 mikrotik 中获得价值。下面是手动 PHP,如果代码从Telnet 到 sisco,则值与此相同,但代码不同。
<?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));
}
?>
我想像我使用这样的命令提示符获得价值
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
但是当我运行代码时,值$line
是
ÿýÿý ÿý#ÿý
不像我想要的,你能给我解决方案吗?