Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Firstly, I am running all of these commands through www-data user..which is apache2 user... Using php, and exec function to run these commands...

I create the directory

mkdir -p testing

Now lets see folders

ls

the directory testing is not showing...although the folder was created ( I check in physical path)

share|improve this question

migrated from stackoverflow.com Apr 24 '11 at 15:59

This question came from our site for professional and enthusiast programmers.

    
Maybe the user www-data has the right to write to the folder, but not read from it? –  Grigory Javadyan Apr 24 '11 at 15:54
    
To prevent problems with working directory always use a full path instead of a relative one. –  Let_Me_Be Apr 24 '11 at 16:02

1 Answer 1

Firstly, make sure that the directory you are writing into a) exists and b) has the right permissions to allow you to read/write to it.

Secondly, try not to use exec, system, or anything like that. Not only is it unsafe (passing args can be a real security hole), but it also adds a large overhead to the operation, having to spawn new sub-processes etc.

Also, using exec() just returns the last line of the command you run. If you really need to use a system program to perform functions then you should either use passthru() to return the data direct to the browser, or shell_exec() if you want to have the output in a string.

share|improve this answer
    
Your answer indicates this is a programming issue. If only the SO folks had read the question before dumping it here... sigh –  Daniel Beck Apr 24 '11 at 16:36
1  
@DanielBeck pfff.. attach them using an inclined plane wrapped helically around an axis. –  Majenko Apr 24 '11 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.