Shell_exec kullanarak Powershell için PHP

1 Cevap php

Ben çalıştırırsanız:

$output = shell_exec('powershell "get-service "dhcp""'); 

Ben çalıştırırsanız Ben çalışan gösteren hizmet dhcp'nin mükemmel çıkış olsun ama:

$output = shell_exec('powershell "get-user "testing""'); 

Ben bir şey olsun.

Im burada ne yaptığını herhangi bir fark görmüyorum - ve neden olsun-hizmet çalışmıyor ama olsun-kullanıcı olmaz. Ben cmd çalıştırırsanız mükemmel çalışıyor. Herhangi bir fikir?

Ben konular apache komutu çalıştıran ve izinleri yok olabilir inanıyoruz. Bu durum olabilir mi? Farklı bir kullanıcı olarak apache çalıştırmak mı? Eğer öyleyse bunu yapmak erişimi yok.

1 Cevap

Eğer bir hata görürseniz görmek için standart çıktıya hata çıktı yönlendirme sahipsiniz.

$output = shell_exec('powershell "get-user "testing" 2>&1"'); 

http://www.aboutdebian.com/nettools.txt alınan bu pasajı

//Normally, the shell_exec function does not report STDERR messages. 
//The   "2>&1"          option tells the system 
//to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");