Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the problem that when I try to copy some files from php I get the response that it failed, but the file is actually copied. This is a problem since I log an error message and exit the script when it fails but there are still plenty left for the script to do.

I've tried two different ways of copy:

if(!copy("/var/www/html/smicadmin.properties", "/etc/conf/".$new_dir."/smicadmin.properties"))

if(shell_exec("cp $src $dest")==null)

I have labeled 'conf' in order for SELinux to allow apache to write to it:

chcon -R -t httpd_sys_script_rw_t /etc/conf

Does anyone have any clue why this can happen and how to fix it?

share|improve this question
    
What exactly response do you get? –  FractalizeR May 16 '12 at 13:35
add comment

1 Answer

and the answer:

shell_exec will return a string, the output of this program. If it return some "blablabla" and you compares to null it will be false.

use the function exec

http://www.php.net/manual/en/function.exec.php

and compare the return_var with zero -- if success it will be equal to zero, other value in case of failure.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.