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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?