This function is identical to the backtick operator. It is not possible to detect execution failures using this function. In the above example, a line break at the beginning of the gunzip output seemed to prevent shell_exec printing anything else. Hope this saves someone else an hour curl.exe utf-8 two.
There are cases where you need the output to be logged somewhere else though. Using the above command still hangs web browser request. Be careful as to how you elevate privileges to your php script. It’s a good idea to use caution and planing.
It is easy to open up huge security holes. Here are a couple of helpful hints I’ve gathered from experimentation and Unix documentation. If you are running php as an Apache module in Unix then every system command you run is run as user apache. Unix won’t allow privileges to be elevated in this manner. If you need to run a system command with elevated privileges think through the problem carefully!
You are absolutely insane if you decide to run apache as root. You may as well kick yourself in the face. There is always a better way to do it. If you decide to use a SUID it is best not to SUID a script. SUID is disabled for scripts on many flavors of Unix. SUID scripts open up security holes, so you don’t always want to go this route even if it is an option.