I have a script which, given an ID, kicks off some complex processes and puts an RTF file onto stdout. For example, you might call it with something like foo.exe 27 to point it at ID 27.
Now I’d like to write a short PHP page which:
- accepts a GET
idparameter - checks that the parameter is an integer number
- calls
shell_exec(...)on the script (we’ll assume it’s on the$PATH) - responds with the output of the script, popping up the usual browser-specific download prompt, just as if they’d clicked on the file in a link
Can this be done easily?
This should be pretty simple. Just what you need is to make sure you’re not inserting weird data to the script, to avoid any breaks, and to redirect STDERR to STDOUT to avoid to have errors and not to be able to see them.
Hope it helps!