douyuqing_12345 2011-08-08 22:21
浏览 24

too long

I'm trying to print the host/ip to the screen. But, it's printing: "Resource id #2" instead. I'm using SSH2_connection(). I read the doc page and know the the function parameters are host, port, methods ... but when I try fread($host), the host/ip is still not printing can someone give me some direction on this? Thanks!

Code:

 <?php
 if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
 if(!($ssh = ssh2_connect('10.5.32.12', 22))) {
     echo "fail: unable to establish connection
"; 
 } else {

     if(!ssh2_auth_password($ssh, 'root', '********')) {
        echo "fail: unable to authenticate
";
     } else {
         echo "Okay: Logged in  ... ";
         $content = fread($ssh); //Line in question (want ip address to show here)
         echo "$content <br>";        //Line in quesion
         $stream = ssh2_exec($ssh, 'find / -name *.log -o -name *.txt');   
         stream_set_blocking($stream, true);
         $data = '';
         while($buffer = fread($stream, 4096)) {
             $data .= $buffer;
         }
         fclose($stream);
         echo $data; // user
     }
 }
 ?>
  • 写回答

2条回答 默认 最新

  • doukuanyong1939 2011-08-08 22:23
    关注

    I believe you need the parenthesis around the variabls as well when using double quotes. "{$content} <br>"

    Have you tested with your own debug methods whether the $content variable contains information? You can set a value for the variable to test whether your echo statement is correct syntax.

    评论

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法