Hi all. First post in these forums. I am an experienced C/C++/Java/C# programmer but have never done any web development. I have a pretty basic question about running executables on a server via php. I gather this is not a good idea, basically. I have some (large-ish) programs written in C that I would like to execute and get the results into a browser. Is there a 'safe' way of doing this? I would really rather not reimplement my programs in php if I can possibly avoid that.
Using exec or system should work for this. You need to build an effective interface to handle and return the data you need in php. If you're looking at returning huge amounts of data, this might not be the most effective way to accomplish it.
Thank you. I figured the issue is possibly where you permit the user to enter an executable name which would be a bad idea.
I'm a bit rusty on this, but I think you can just use the backtick operator: $output = `dig www.google.com`; // The backticks contain exactly what you'd normally enter at the commandline var_dump($output); PHP: $output should be an array of strings with the output from the program.