Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
shell scripting the copy of same file to full tree
So what I am hoping for is a shell script or PHP script that will allow me to copy my php.ini file recursively to every folder from my chosen root.
If you want it in every subdirectory, just do it from the command line like this. The '-i' on cp will cause it to prompt you before overwriting an existing file.
$ for dir in $(find . -type d); do cp -i php.ini $dir; done
Thank you for the reply. This command net me a response from the shell of:
-jailshell: syntax error near unexpected token `do'
As a test I just ran this command in my SSH bash shell at my BlueHost-hosted site and it worked fine:Code:
for dir in $(find . -type d); do echo $dir; done
Maybe this would workCode:
find . -type d | while read dir; do cp -i php.ini $dir; done
08-07-2006 #5Originally Posted by KenJackson
I was not using cPanel, but rather I was SSHed into a shell from a term window. So I do not know what jailshell is either. However, my host does use cPanel, but they are very security conscious. I have to sign an affidavit and pay $25 for shell access via SSH, and PHP is setup as cgi through phpsuexec.
It took me a little bit to learn how to get phpsuexec to play nice with some scripts that claim it really won't work well under (like ZenCart), but it wasn't too bad and things run fine now. All you need to do is make sure the max permissions on directories and files is 755 (777 generates a 500 internal server error) and generally you can set directories at 755 and files at 644 and be fine. It seems a lot of scripts seem to think they need higher permissions than they really do. For example they always say to set the upload directory to 777, why does the upload directory need execute permissions?
Well it sounds like you got it to work. But I already thought of a different solution that doesn't require a loop, so I'll mention it anyway. Note the space after the period on the second line.Code:
find . -type d -fprintf copyphp "cp -i php.ini %p\n" . copyphp rm copyphp
I know there is sure some serious power in the shell, but I just don't know how to tap into it. I looks as if you do though.
I just have not had time or occasion to learn, and I am not a scripting type person to begin with. I might learn now though, as I have given up on Windows™ and have been using Ubuntu exclusively for three months now. I have Dreamweaver 8 installed via Wine, and VMWare server so I can use Photoshop CS2, but that is about it. I am still looking for a good FTP client. gFTP sucks, it just dies out of no where, the Linux nightly of FileZilla is functional and fast as hell, but it is feature light and the interface leaves something to be desired. I sure would like to find a robust feature rich FTP client like AbsoluteFTP on Windows™
Thanks again for you help.