douyi1899 2019-08-12 13:50
浏览 112

exec没有返回powershell响应

I'm making a web page for the association I work for to check the daily data. For each data in the array, there is a background-color that is green if the data exists and red if it's not the case. The data I'm looking for is located on severals servers I can access to thanks to PowerShell with the cmd powershell.exe Invoke-Command -Computer Server -ScriptBlock {Test-Path the_path_to_my_file}, but when I make an exec function in php with this line in first argument and an array in second argument, the array remains empty.

I've tried this on my professional computer and it works but I have to log in to the server to access the data because I'm not administrator, but the web page is located on a server I administrate.

I know I can access the server with the cmd powershell.exe Invoke-Command -Computer Server -ScriptBlock {Test-Path the_path_to_my_file} and the exec command works with an echo for example.

I've also tried with passthru and SHell_Exec and there is no result either

function existe_srv($srv, $file){
      exec("powershell.exe Invoke-Command -Computer ".$srv." -ScriptBlock {Test-Path \"".$file."\"}", $out );
      if ($out[0] == True){return 'RGB(0,255,0)';}
      else {return 'RGB(255,0,0)';}
    }

background-color:
Notice: Undefined offset: 0 in D:\XAMP\htdocs\Test_opti_cartes\supervision_donnees_quotidiennes.php on line 37

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?