exec("cp -a", $output, $error)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

exec("cp -a", $output, $error)

Post by mad_phpq »

Not working on my server.

I have given write permissions for www-data (apache user) in this folder ($dir) and it will not work.

Code: Select all

 
 
$dir = '/www/folder';
 
exec("cp -a $dir/* $dir/testfolder", $output, $error);
 
 
Thanks in advance!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: exec("cp -a", $output, $error)

Post by VladSun »

Try

Code: Select all

echo exec("cp -a $dir/* $dir/testfolder 2>&1");
There are 10 types of people in this world, those who understand binary and those who don't
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

Re: exec("cp -a", $output, $error)

Post by mad_phpq »

Code: Select all

cp: target `/www/dle_creator/testfolder' is not a directory
will not create the folder i take it.... can this be done.... I've had the same problem with mkdir() earlier today, with the same outcome.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: exec("cp -a", $output, $error)

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

Re: exec("cp -a", $output, $error)

Post by mad_phpq »

the command works inside ssh, but not through php.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: exec("cp -a", $output, $error)

Post by VladSun »

Code: Select all

mkdir -p
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply