我有这个利用 ssh 的 php 脚本。我的 php 安装在 c:\php 目录中。当我直接从该目录运行此脚本时,它可以工作。但是,如果我尝试使用绝对路径从其他目录运行此脚本,则会出现各种错误:
C:\inetpub\wwwroot>c:\php\php c:\php\get_cpu1.php
PHP Warning: require_once(Math/BigInteger.php): failed to open stream: No such file or directory in C:\PHP\Net\SSH2.php on line 746
Warning: require_once(Math/BigInteger.php): failed to open stream: No such file or directory in C:\PHP\Net\SSH2.php on line 746
PHP Fatal error: require_once(): Failed opening required 'Math/BigInteger.php' (include_path='C:/PHP/pear') in C:\PHP\Net\SSH2.php on line 746
Fatal error: require_once(): Failed opening required 'Math/BigInteger.php' (include_path='C:/PHP/pear') in C:\PHP\Net\SSH2.php on line 746
有什么想法我在这里想念的吗?
这是 get_cpu1.php 的代码
<?php
include('C:/PHP/Net/SSH2.php');
$ssh = new Net_SSH2('server1.example.com');
if (!$ssh->login('user', 'passwd')) {
exit('Login Failed');
}
//echo $ssh->exec('pwd');
$line= $ssh->exec('tail -1 /var/log/messages');
//echo $line;
unset($ssh);
?>