Reputation: 339
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?
Upvotes: 0
Views: 550
Reputation: 2217
I usually simply use:
passthru("the_command 2>&1");
the 2>&1 bit is to redirect STDERR to STDOUT, which is where your output probably is, when the command fails...
Upvotes: 1