Jump to content

[SOLVED] system exec


jaymc

Recommended Posts

Im trying to copy the entire contents of 1 folder to another, im using shell commands via php system or exec command, its not working though

 

system("cp -ap $dir_to_read/$file/. $dir_to_read");

exec("cp -ap $dir_to_read/$file/. $dir_to_read");

 

That returns cp -ap 'BaseFolder/folder/.' 'BaseFolder' and if I copy and paste that straight into ssh it works fine, so its not the syntax or the variables

 

All the folders in question are 777 etc etc, I have rights to use system command as its my server and I have enabled that

 

Any ideas

 

P.S - If there is another way to do it, please let me know

 

My mission is to copy the contents of a folder via "." the dot, rather than read all the files etc. I have my reasons

 

I tried copy("$dir_to_read/$file/.", $dir_to_read); but where I have $dir_to_read it also wants a new file name, so it wont work as there can be several files

Link to comment
Share on other sites

shell_exec("cp -a $dir_to_read/$file/. $dir_to_read");

//exec("cp -a $dir_to_read/$file/. $dir_to_read");

//system("cp -ap $dir_to_read/$file/. $dir_to_read");

//copy("$dir_to_read/$file/.", $dir_to_read);

 

P.S - I have had commands like gunzip unrar etc working with exec just incase you think thats the issue

Link to comment
Share on other sites

shell_exec("cp -a $dir_to_read/$file/. $dir_to_read");

//exec("cp -a $dir_to_read/$file/. $dir_to_read");

//system("cp -ap $dir_to_read/$file/. $dir_to_read");

//copy("$dir_to_read/$file/.", $dir_to_read);

 

P.S - I have had commands like gunzip unrar etc working with exec just incase you think thats the issue

 

shell_exec("cp -a $dir_to_read/$file/\. $dir_to_read");

 

I think you needed to escape that . after the first location because PHP thinks it's trying to concatenate something.  Try this new line.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.