Results 1 to 7 of 7
I am not much the scripter and I was hoping for some help by the shell geniuses out there. My web host runs PHP as a cgi through phpsuexec. They ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-07-2006 #1
shell scripting the copy of same file to full tree
I am not much the scripter and I was hoping for some help by the shell geniuses out there. My web host runs PHP as a cgi through phpsuexec. They also have register_globals as on by default. The consequences of this is that the normal method to override this setting will not work. Normally a person could do this with an option in the .htaccess file in the root of the directory you wish to effect, and it effects of the option change filter down recursively to all subdirectories. Well I have a PHP script that behaves very badly if register_globals is on. The override under the phpsuexec system is a php.ini file IN EVERY DIRECTORY IT NEEDS TO EFFECT. Fortunately, my host gives me SSH shell access.
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.
- 08-07-2006 #2
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
- 08-07-2006 #3
Thank you for the reply. This command net me a response from the shell of:
-jailshell: syntax error near unexpected token `do'
- 08-07-2006 #4
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?
- 08-07-2006 #6
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
- 08-08-2006 #7
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.