1
我想从我的服务器中检索运行在远程服务器上的处理器数量。 要做到这一点,我用这个命令行来检查的信息:当使用PHP时,PSEXEC访问被拒绝
C:\Users\Administrator>psexec -accepteula \\remote_computer_name -u remote_computer_name\admin -p my_password cmd /C "set number_of_processors"
,并返回我想要的结果:
但是,当我试图以检索相同的结果在PHP脚本中使用它,它表示访问被拒绝。
PSEXEC v1.98 - 执行过程远程版权所有(C)2001-2010马克 Russinovich编写的Sysinternals - www.sysinternals.com
访问被拒绝。
连接到remote_computer_name ......在remote_computer_name开始PSEXEC 服务...不能在 remote_computer_name启动PSEXEC服务:连接到remote_computer_name ...开始PSEXEC上remote_computer_name 服务...
这里是我的PHP脚本:
<?php
function executeCmd($cmd,$params,$return)
{
//$resTable = array();
$resInt = -1;
exec("$cmd $params",$resTable,$resInt);
//$resTable=shell_exec($cmd $params);
//print_r($resTable);
if($return == 40)// return associative table
return $resTable;
if($return == 41)// return int
return $resInt;
}
$cmd = "psexec";
$params = " -accepteula \\\\remote_computer_name -u remote_computer_name\\admin -p password cmd /C \"set number_of_processors\" 2>&1";
//$res = system($cmd,$params,40);
$res = executeCmd($cmd,$params,40);
for($i=0;$i<count($res);$i++)
{
print_r($res[$i]);
echo "</br>";
}
?>
我在另一对服务器上使用相同的脚本,它工作得很好。我错过了什么 ?