My Apache2 needs to run a Windows file which works perfectly under command line.
It is a simple C++ debug code that does the following:
Code: Select all
#include <iostream>
#include <fstream>
#include <unistd.h>
int main(int argc, char *argv[])
{
std::ofstream file("FILE_TO_WRITE");
file << "Hello World" << std::endl;
file.close();
std::cout << "STARTING" << std::endl;
/*
for (int i = 0; i < 5000; i++)
{
std::cout << i << std::endl;
usleep(900000);
}*/
std::cout << "ENDING" << std::endl;
return 0;
}
To trigger them, I use the following PHP script:
Code: Select all
<?php
exec("./main 2>&1", $output, $return_var);
var_dump($output);
echo "\nReturnVar: $return_var";
?>
However, running the PHP script with 'wine main.exe' throws back:array(2) { [0]=> string(8) "STARTING" [1]=> string(6) "ENDING" } ReturnVar: 0
Although, both commands work perfectly from command line (to note doing './main.exe' works perfectly).array(0) { } ReturnVar: 159
My question is: how come Apache struggles to start my Windows file and how would I be able to have it start it ?
UPDATE: After looking in Apache error logs, here is what I have when executing the Windows file:
Thanks for your help !sh: line 1: 10677 Bad system call ./main.exe 2>&1