2019-08-12 13:50
浏览 98


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)';}

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

图片转代码服务由CSDN问答提供 功能建议

我正在为我工​​作的关联创建一个网页来检查每日数据。 对于每个数据 如果数据存在,则存在背景颜色为绿色,如果不存在则为红色。 感谢PowerShell使用cmd powershell.exe Invoke-Command -Computer Server -ScriptBlock {Test-Path the_path_to_my_file} ,我正在寻找的数据位于我可以访问的多个服务器上,但是当我 使用第一个参数中的这一行和第二个参数中的数组在php中创建一个exec函数,该数组保持为空。

我在我的专业计算机上尝试了这个并且它有效但我有 登录到服务器以访问数据,因为我不是管理员,但网页位于我管理的服务器上。

我知道我可以使用cmd访问服务器 powershell.exe Invoke-Command -Computer Server -ScriptBlock {Test-Path the_path_to_my_file} ,exec命令用于 echo ,例如。


  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)';} 

注意:未定义的偏移量:0 在 D:\ XAMP \ htdocs \ Test_opti_cartes \ supervision_donnees_quotidiennes.php 37

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答