Php exec function doesn't work as expected
-
I am using exec function in a php script, if I run the script in command line, such as "php xx.php", the exec function will be executed, but if i access the php page from a browser, then the exec function will not run. Anyone known how to solve the problem? Thanks.
-
Answer:
Is the script trying to create/edit/delete files? Try making the files and the containing directory writeable by the web server. If you're trying to add a file, navigate to the folder you're adding it to and run the following: chmod go+w .. If you're trying to delete/edit a file, trying the following: chmod go+w myfile.txt. When running a script from the command line it runs as the logged in user, whereas when running it through a browser it is run as the web server user (usually a user named www.) This user generally doesn't have write access to the files and directories that are being served.
cheng at Stack Overflow Visit the source
Other answers
Check your phpinfo() output to see if safe mode is enabled. Also check to see if suhosin or mod_security are enabled. All of these can limit your ability to use exec()...
philwinkle
You can use "2>&1" as succeeding with the command which you are trying to execute with exec(). for example: - exec( php xx.php 2>&1", $output); Then you can trace the problem by print output.
mahadeb
Related Q & A:
- How come CD doesn't work in my shell script?Best solution by Super User
- Youtube doesn't work on iphone?Best solution by answers.yahoo.com
- Google doesn't work (google.com) on any computer?Best solution by Yahoo! Answers
- Yahoo Music Doesn't Work?Best solution by Yahoo! Answers
- Mail search doesn't work?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.