doubeng9567 2014-12-16 17:23
浏览 157

无法通过telnet PHP登录服务器

I'm using a [PHP Telnet Class][1] to connect to server via telnet to send commands. It connects to the server successfully but it fails to login in..

require_once "PHPTelnet.php";

$telnet = new PHPTelnet();

// if the first argument to Connect is blank,
// PHPTelnet will connect to the local host via 127.0.0.1

$result = $telnet->Connect('172.20.66.100','username','password');

if ($result == 0) {
   $telnet->DoCommand('another command', $result);

   echo $result;
   $telnet->Disconnect();}

=============================================================================== UPDATE: My script is working, there was some conflict going on with my virtual machine......

  • 写回答

2条回答 默认 最新

  • dongyu3659 2014-12-16 17:35
    关注

    Try this:

        $url = 'tcp://ADDRESS_HERE:PORT_HERE';
        $fp = stream_socket_client($url, $errno, $errstr, 10);
        if (!$fp) {
            echo ("$errstr ($errno)<br />
    ");
            exit;
        } else {
            $command = 'execute_command_line' . PHP_EOL;
            fwrite($fp, $out);
    
            stream_set_blocking($fp, true);
    
            while (!feof($fp)) {
                $output = stream_get_contents($fp);
            }
    
            fclose($fp);
            echo output;
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题