dongmiao260399 2014-12-02 09:54
浏览 145
已采纳

php中的ssh2_exec无法正常工作

I am tryin to send a exec command in php to a remote server(aerohive). but the exec command does nothing..

I have my ssh2 extension installed and the authetication is also working fine.

Here is the code :

        if (!function_exists("ssh2_connect"))
        die("function ssh2_connect doesn't exist");

    if (!($con = ssh2_connect("myipadresherenotshowingtoyouguys", 22))) {
        echo "fail: unable to establish connection
";
    } else {
        // try to authenticate with username root, password secretpassword
        if (!ssh2_auth_password($con, "blablabla", "blablabla!")) {
            echo "fail: unable to authenticate
";
        } else {
            // allright, we're in!
            echo "okay: logged in...
";

            // execute a command
            $command = 'ssid "Wentzo test2" hide-ssid';
            if (!($stream = ssh2_exec($con, $command))) {
                echo "fail: unable to execute command
";
            } else {

                $stream2 = ssh2_exec($con, $command_save);
                // collect returning data from command
                stream_set_blocking($stream, true);
                $data = "";
                while ($buf = fread($stream, 4096)) {
                    $data .= $buf;
                }

                fclose($stream);
            }
        }
    }
  • 写回答

1条回答 默认 最新

  • dongwen7371 2014-12-02 11:17
    关注

    Check the file php.ini if it does disabled the function disable_functions

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!