I've a program which must be runned from cmd.exe and be supplid a few parameters. The command looks like this:
query.exe USERNAME PASSWORD WMI_QUERY MACHINE
This program is working fine. But when I try to run it from PHP with the following code:
function execute_query($ip, $username, $password, $query){
$runCMD ="query.exe " . $username . " " . $password . ' "' .$query . '" ' . $ip;
echo exec($runCMD);
print_r ($stdout);
}
I don't get any output. It says that the process terminated successfully, but nothing else, although the program runs and returns the output successfully. I'm using windows and XAMPP with php 7.1 I tired using shell_exec, but didn't have any luck. Any other ideas?
exec()returns output in an array for each line of output in the terminal. iirc shell_exec does not return anything. check the array param that is passed by reference - php.net/manual/en/function.exec.php$runCMD.