无法将ssh执行中的数据回显到PHP中的网页

无法将ssh执行中的数据回显到PHP中的网页,php,ssh,Php,Ssh,我正在编写一个PHP脚本,从用户(如服务器IP)获取输入,然后再输入一个 在这可用之后,我对服务器进行ssh调用并执行一些命令。我想在网页上显示输出,但得到的错误为500(服务器错误) 这是我的主脚本,我从用户那里获得输入: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html

我正在编写一个PHP脚本,从用户(如服务器IP)获取输入,然后再输入一个

在这可用之后,我对服务器进行ssh调用并执行一些命令。我想在网页上显示输出,但得到的错误为500(服务器错误)

这是我的主脚本,我从用户那里获得输入:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Centos Health Checker</title>
<link rel="stylesheet" href="style.css" type="text/css" />

</head>
<body>
<center>
<div id="login-form">
<form method="post" action="redirectPage.php">
<table align="center" width="30%" border="0">
<tr>
<td><input type="text" name="IP" placeholder="System IP" required /></td>
</tr>
<tr>
<td><input type="text" name="Component" placeholder="Component" required /></td>
</tr>
<tr>
<td><button type="submit" name="submit">Check System</button></td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>

Centos健康检查器
检查系统
这是我的登录页:

<?php
function Connect()
{
        include('/home/as5714/php_data/Net/SSH2.php');
        $IP1 = $_POST['IP'];
        $Component1 = $_POST['Component'];

        $ssh = new Net_SSH2($IP1);
        if (!$ssh->login('centos', 'centos')) {
            exit('Login Failed');
        }

        echo $ssh->exec('pwd');
        echo $ssh->exec('ls -la');
}

if(isset($_POST['submit']))
{
        Connect();
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $IP1; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
 <div id="left">
    <label>cleartuts</label>
    </div>
    <div id="right">
     <div id="content">
         Cennecting to ' <?php echo $IP1; ?>&nbsp; and Data is : <?php echo $data2; ?>&nbsp;<a href="homePage.php">Go Back</a>
        </div>
    </div>
</div>
</body>
</html>

欢迎-
cleartuts
连接到“”和“”的数据是:
我在使用上述php代码时遇到服务器错误(500)

请注意,我正在linux服务器上为脚本使用vim编辑器,没有任何可用的日志。另外,如果我只运行程序直接在服务器(php123.php)中进行ssh连接和执行命令,我将在控制台上获得正确的数据


请提供帮助。

与500一样,查看服务器的错误日志以了解有关500的详细信息。在代码中反复尝试找出问题所在,而您只需查找问题的真正所在,这是没有意义的。谢谢。我启用了日志记录,并让它在不抛出500的情况下工作。但我只能在Connect()函数中使用echo打印数据。如果我在其他地方做回音。我没有获取数据值。通过在末尾关闭函数connect()使其正常工作。与500一样,查看服务器的错误日志以了解有关500的详细信息。在代码中反复尝试找出问题所在,而您只需查找问题的真正所在,这是没有意义的。谢谢。我启用了日志记录,并让它在不抛出500的情况下工作。但我只能在Connect()函数中使用echo打印数据。如果我在其他地方做回音。我没有获取数据值。通过在末尾关闭函数connect()使其工作。