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
https://forums.phpfreaks.com/topic/102545-solved-system-exec/
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
https://forums.phpfreaks.com/topic/102545-solved-system-exec/#findComment-525043
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
https://forums.phpfreaks.com/topic/102545-solved-system-exec/#findComment-525052
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.