当前位置: 首页>>代码示例>>PHP>>正文


PHP Net_SSH2::getLog方法代码示例

本文整理汇总了PHP中Net_SSH2::getLog方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SSH2::getLog方法的具体用法?PHP Net_SSH2::getLog怎么用?PHP Net_SSH2::getLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_SSH2的用法示例。


在下文中一共展示了Net_SSH2::getLog方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Exec

 public function Exec($command)
 {
     $engine = $this->session->getSpooler();
     if (!isset($engine[0]['shell'])) {
         print "?!";
         exit;
     }
     $shell = $engine[0]['shell'];
     $host = $shell['host'];
     $user = $shell['user'];
     $password = $shell['password'];
     $method = 'CURL';
     set_include_path(get_include_path() . PATH_SEPARATOR . '../vendor/phpseclib');
     include 'Net/SSH2.php';
     include 'Crypt/RSA.php';
     $ssh = new \Net_SSH2($host);
     if (1) {
         $key = new \Crypt_RSA();
         $ret = $key->loadKey("-----BEGIN RSA PRIVATE KEY-----\nMIICWgIBAAKBgQCzRy01HoHIzBJJb/D8A/eTV3qiZxy0NIR97NE14rJblnJZT5Kg\noP2DvIRzlB0msL5cHQJ/qXYAoemHRDKqNZuj89+MYsBeZqNu3/DXdZLq9XJ8e2rb\nsGrDjHvCHEDWL0JIRFnRacem55+XsUsKTIs4tbcD6adMPIYJSQQ7oB/8AQIBIwKB\ngB67vptkUMNWLwVGY9NuZPSv6SMnnoVK1OJjHIzlCKH8iKGYnMsUSLd/ZynBnpjr\nGVGekrbMl+LZ7YTnHqDV/WxGoWEc3xiHE8/HwZwQZxP92K70inz8+6dGEagsrSqO\nQkdAPR/+qen7uQ9yXqj7WAoNFicPJ2cpo8kuEW33KywzAkEA4yH4jf0uNBFDUkR6\ni9DQC5bsgEloVezWnCsm6eIm5o5SGKPZ6Rpro/h3pq5qvPmCtjrZFnK0Dab9xkFr\n/F9lkwJBAMoQMqxYdnPz74Bto99o0PZrk2ikROwXR9eURi3B4bWGq9+mvN3OEQdE\n8JofGyq60LMlnFAkE7v49fYHziyaFJsCQHTPpGZHsVybKe/LcjlG0WULyhYXH7cp\nWG2SiQqRkFlQgf4LH5xz/Nf8IEcX3x9bv5DrEI8zrQ5V4Zko9bT93HcCQQCEyNDX\np9jP2tCWOWuwEa3jwwkY4PoXfQNTJuxJ9G/AbnDyDnwcup15zje1vKtz2dmaS+pg\njLyC1s2Ea4d8ZUC9AkAeUr/N+011K2zGTjxZnAFY/Ow348bomzddiJYAYA+76exV\n3wUYsjeDxqq8Km93+iMQ8DDNZIvoVcfYQW9BfDlf\n-----END RSA PRIVATE KEY-----   ");
         if (!$ret) {
             echo "loadKey failed\n";
             print "<pre>" . $ssh->getLog() . '</pre>';
             exit;
         }
     } elseif (isset($shell['password'])) {
         $key = $shell['password'];
     } else {
         $key = '';
         // ?! possible ?
     }
     if (!$ssh->login($user, $key)) {
         exit("Login Failed ({$user})");
     }
     return $ssh->exec("system '{$command}'");
 }
开发者ID:AriiPortal,项目名称:I5Bundle,代码行数:35,代码来源:AriiExec.php

示例2: Exec

    public function Exec($command, $stdin = '')
    {
        $database = $this->session->getDatabase();
        $name = $database['name'];
        $engine = $this->session->getSpoolerByName($name, 'waae');
        if (!isset($engine[0]['shell'])) {
            print "?!";
            exit;
        }
        set_include_path('../vendor/phpseclib' . PATH_SEPARATOR . get_include_path());
        include 'Net/SSH2.php';
        include 'Crypt/RSA.php';
        $shell = $engine[0]['shell'];
        $host = $shell['host'];
        $user = $shell['user'];
        $ssh = new \Net_SSH2($host);
        if (isset($shell['key'])) {
            $key = new \Crypt_RSA();
            $ret = $key->loadKey($shell['key']);
            if (!$ret) {
                echo "loadKey failed\n";
                print "<pre>" . $ssh->getLog() . '</pre>';
                exit;
            }
        } elseif (isset($shell['password'])) {
            $key = $shell['password'];
        } else {
            $key = '';
            // ?! possible ?
        }
        if (!$ssh->login('autosys', $key)) {
            print 'Login Failed';
            print "<pre>" . $ssh->getLog() . '</pre>';
            exit;
        }
        if ($stdin == '') {
            return $ssh->exec(". ~/.bash_profile;{$command}");
        }
        // Test STDIN
        $ssh->enablePTY();
        print "profile" . $ssh->exec(". ~/.bash_profile");
        print "sort" . ($exec = $ssh->exec('sort'));
        $ssh->write(<<<EOF
echo "update_job: SE.ERIC.JOB.JobType_UNIX"
echo "description: 'ok!!'
EOF
);
        $ssh->reset(true);
        $ssh->setTimeout(2);
        print $ssh->read();
        return;
        return $ssh->read();
        // outputs the echo above
    }
开发者ID:AriiPortal,项目名称:ATSBundle,代码行数:54,代码来源:AriiExec.php

示例3: Exec

 public function Exec($shell, $command, $stdin = '')
 {
     $host = $shell['host'];
     $user = $shell['user'];
     $ssh = new \Net_SSH2($host);
     if (isset($shell['key'])) {
         $key = new \Crypt_RSA();
         $ret = $key->loadKey($shell['key']);
         if (!$ret) {
             $this->status = '!KEY';
             echo "loadKey failed\n";
             print "<pre>" . $ssh->getLog() . '</pre>';
             return;
         }
     } elseif (isset($shell['password'])) {
         $key = $shell['password'];
     } else {
         $key = '';
         // ?! possible ?
     }
     if (!@$ssh->login($shell['user'], $key)) {
         $this->status = '!LOGIN';
         print 'Login Failed: ' . $shell['user'];
         print "<pre>" . $ssh->getLog() . '</pre>';
         return;
     }
     $this->status = 'RUNNING';
     if ($stdin == '') {
         return $ssh->exec("{$command}");
     }
     return;
 }
开发者ID:AxelANGENAULT,项目名称:CoreBundle,代码行数:32,代码来源:AriiExec.php

示例4: str_repeat

$dh_pid = trim(preg_replace('/\\s+/', ' ', $dh_pid));
echo "Start.{$dh_pid}.END<br />";
//$dh_pid = "11192";
//$dh_pid_result = $ssh->exec("pgrep -fl ".$dh_pid."");
//echo "<hr>";
//echo $ssh->exec("ls");
//echo "<hr>";
$dh_pid_result = $ssh->exec("ps aux | grep {$dh_pid} | grep -v grep");
$ssh->setTimeout(10);
//$dh_pid_result = $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX);
echo "<pre>{$dh_pid_result}</pre>";
echo str_repeat(' ', 1024 * 64);
//need SECOND occurance of $needle since the result will include the actual command
//$dh_after_first_result = stristr($dh_pid_result, $dh_pid);
if (stristr($dh_pid_result, $dh_pid) === TRUE) {
    echo "DH not completed.... waiting...";
    sleep(15);
    echo str_repeat(' ', 1024 * 64);
    if (stristr($dh_pid_result, $dh_pid) === TRUE) {
        echo "DH STILL not completed.... waiting...";
        sleep(15);
        if (stristr($dh_pid_result, $dh_pid) === TRUE) {
            echo "<hr>DH STILL NOT COMPLETED.... manually run <br />source ./vars and ./build-dh in {$var_dir} then <br />copy dh1024.pem from {$key_dir} to config directory (usually /etc/openvpn)<hr>";
            echo $ssh->getLog();
            exit;
        }
    }
}
echo str_repeat(' ', 1024 * 64);
echo $ssh->getLog();
exit;
开发者ID:istrwei,项目名称:OpenVPN-PHP-Management-Gui,代码行数:31,代码来源:test.php


注:本文中的Net_SSH2::getLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。