0

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?

1

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .