tags:

views:

427

answers:

1

If I run:

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

I get perfect output of the service dhcp showing running but if I run:

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

I get nothing.

I don't see any difference in what Im doing here - and why get-service would work but get-user would not. If I run it in cmd it works perfectly. Any ideas?

I believe the issues might be that apache is running the command and does not have permissions. Could this be the case? Does apache run as a different user? If so it doesn't have access to do this.

+1  A: 

Try redirecting the error output to the standard output to see if you can see an error.

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

This snippet taken from http://www.aboutdebian.com/nettools.txt

//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");
thedugas