Hello,
I have recently come into a rather fustrating problem related to the PHP exec();
I ideally want to run something like the following c++ compiled .exe...
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
ofstream myfile;
myfile.open ("file.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
... using exec("out.exe");
What this should do is write to a file called file.txt in the script root directory.
I know its running because if I add an api beep to it, I hear it. It just cannot seem to write.
I can get this to work in IIS 5 by changing the application protection to the top one (low security or something)
Ideally though I need this to work for Apache 2.x.x
It seems to me that PHP is running the app but not allowing it writing permissions... I cant quite understand because I ran it in IIS under Administrator and it still didn't work until I changed that Application protection thing. Unfortunately I have very little experience with Apache so am completely lost as to how to solve this one.
Any help would be much appreciated!
regards,
Karsten
ps. This is exactly what I did on IIS, I simply need to know the apache equilivent 🙂
When trying to run an external command-line application in Windows 2000 (Using IIS),
I found that it was behaving differently from when I manually ran it from a DOS prompt.
Turned out to be an issue with the process protection. Actually, it wasn't the
application itself that was having the problem but one it ran below it! To fix it,
open computer management, right-click on Default Web Site, select the Home Directory
tab and change Application Protection to 'Low (IIS Process)'.
Note, this is a rather dangerous thing to do, but in cases where it's the only option...