Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从其他目录运行php脚本_Php - Fatal编程技术网

如何从其他目录运行php脚本

如何从其他目录运行php脚本,php,Php,我有一个利用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

我有一个利用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
你知道我错过了什么吗

这是获取_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);
?>

解决这个问题的一种方法是使用
cd(\uuuuu DIR\uuuu)脚本中的第一件事


如果您的版本比PHP5.3旧,请改用它:
cd(dirname(_文件__))

请发布get_cpu1.php的代码。尝试使用php cli运行了吗?您认为这是一个正确的问题吗?在include路径错误的地方,您给了我们一个错误,但您从未让我们相信它没有错。您还没有告诉我们Math目录在哪里,以及.php文件中包含什么。我对这个问题投了反对票。@J08691,我也放置了php代码。@Royal Bg,谢谢您的评论。我正在学习PHP,寻找真知灼见。